Repository navigation
Add check_resources hook for resource checks in check_case_data #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7367c55
Add `check_resources` hook called from `check_case_data` (#107)
espenbodal 86b6513
Link res_types_vec instead of resource_family in the check docstrings
espenbodal 9f94978
Apply review comments on check_resources (#107)
espenbodal 164d541
Merge branch 'main' of https://github.com/EnergyModelsX/EnergyModelsB…
espenbodal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,7 +61,7 @@ function check_data(case, modeltype::EnergyModel, check_timeprofiles::Bool) | |
|
|
||
| # Check the case data. If the case data is not in the correct format, the overall check | ||
| # is cancelled as extractions would not be possible | ||
| check_case_data(case) | ||
| check_case_data(case, modeltype, check_timeprofiles) | ||
| log_by_element["Case data"] = logs | ||
| if ASSERTS_AS_LOG | ||
| compile_logs(case, log_by_element) | ||
|
|
@@ -121,16 +121,18 @@ function compile_logs(case, log_by_element) | |
| end | ||
|
|
||
| """ | ||
| check_case_data(case) | ||
| check_case_data(case, modeltype::EnergyModel, check_timeprofiles::Bool) | ||
|
|
||
| Checks the `case` dictionary is in the correct format. | ||
|
|
||
| ## Checks | ||
| - The individual elements vector must be unique, that it is not possible to have two vector | ||
| of nodes within the elements vector. | ||
| - Check that the coupling functions do return elements and not only an empty vector | ||
| - Call of [`check_resources`](@ref) for every resource type segment | ||
| ([`res_types_vec`](@ref)) of the products of the case. | ||
| """ | ||
| function check_case_data(case) | ||
| function check_case_data(case, modeltype::EnergyModel, check_timeprofiles::Bool) | ||
| 𝒳ᵛᵉᶜ = get_elements_vec(case) | ||
| get_vect_type(vec::Vector{T}) where {T} = T | ||
| vec_types = [get_vect_type(x) for x ∈ 𝒳ᵛᵉᶜ] | ||
|
|
@@ -156,6 +158,28 @@ function check_case_data(case) | |
| end | ||
| end | ||
|
|
||
| # Check the resources of the case per resource family | ||
| for 𝒫ˢᵘᵇ ∈ res_types_vec(get_products(case)) | ||
| check_resources(case, 𝒫ˢᵘᵇ, modeltype, check_timeprofiles) | ||
| end | ||
|
Comment on lines
+162
to
+164
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See previous answer. |
||
| end | ||
|
|
||
| """ | ||
| check_resources(case, 𝒫ˢᵘᵇ::Vector{<:Resource}, modeltype::EnergyModel, check_timeprofiles::Bool) | ||
|
|
||
| Check the resources `𝒫ˢᵘᵇ` of a single resource type segment ([`res_types_vec`](@ref)) of | ||
| the `case`. | ||
|
|
||
| The default method does not check anything; extension packages that introduce resource types | ||
| provide methods for their resource types. | ||
| """ | ||
| function check_resources( | ||
| case, | ||
| 𝒫ˢᵘᵇ::Vector{<:Resource}, | ||
| modeltype::EnergyModel, | ||
| check_timeprofiles::Bool, | ||
| ) | ||
| return nothing | ||
| end | ||
|
|
||
| """ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is whether that should be invoked directly here or could be a different PR. Given the description, it would not be necessary to have it here while I agree that Issue #107 states that it should be included. In this case, however, the question is where it is based located. As this is still up to debate, I would leave it at the moment be and ignore this comment.