Skip to content

Add check_resources hook for resource checks in check_case_data - #109

Merged
espenbodal merged 4 commits into
mainfrom
enhance/check_resources
Oct 28, 2026
Merged

espenbodal merged 4 commits into
mainfrom
enhance/check_resources

Conversation

@espenbodal

Copy link
Copy Markdown
Member

Closes #107. Adds check_resources(case, 𝒫ˢᵘᵇ, modeltype, check_timeprofiles), called from check_case_data for every resource family; the default checks nothing. check_case_data gains the arguments modeltype and check_timeprofiles. See the issue for the discussion. Includes tests, NEWS entry and documentation.

@espenbodal
espenbodal requested review from JulStraus and a balanced review from Copilot October 8, 2026 13:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The linked issue’s element-level hook and resource log grouping are missing, and two documentation links are unresolved.

3 open findings
What changed in this PR

Adds resource-level validation to the case consistency-checking framework.

Changes:

  • Adds the check_resources extension hook.
  • Adds resource-check tests and extension guidance.
  • Updates internal documentation and release notes.
File Description
src/​checks.jl Implements and invokes the resource-check hook.
test/​test_checks.jl Tests custom resource validation.
docs/​src/​how-to/​extend-resource-functionality.md Documents implementing resource checks.
docs/​src/​library/​internals/​functions.md Lists the new internal function.
NEWS.md Records the new API.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread src/checks.jl

# Check the resources of the case per resource family
for 𝒫ˢᵘᵇ ∈ res_types_vec(get_products(case))
check_resources(case, 𝒫ˢᵘᵇ, modeltype, check_timeprofiles)

Copy link
Copy Markdown
Member

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.

Comment thread src/checks.jl
Comment on lines +162 to +164
for 𝒫ˢᵘᵇ ∈ res_types_vec(get_products(case))
check_resources(case, 𝒫ˢᵘᵇ, modeltype, check_timeprofiles)
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous answer.

Comment thread src/checks.jl Outdated
- 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 family ([`resource_family`](@ref)) of

@JulStraus JulStraus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too many things to adjust. There is however an issue that we only consider ResourceEmits that are included in the case description. Any other Resources directly in the case description do not matter.

That is however something we have to consider separately.

Comment thread src/checks.jl

# Check the resources of the case per resource family
for 𝒫ˢᵘᵇ ∈ res_types_vec(get_products(case))
check_resources(case, 𝒫ˢᵘᵇ, modeltype, check_timeprofiles)

Copy link
Copy Markdown
Member

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.

Comment thread src/checks.jl
Comment on lines +162 to +164
for 𝒫ˢᵘᵇ ∈ res_types_vec(get_products(case))
check_resources(case, 𝒫ˢᵘᵇ, modeltype, check_timeprofiles)
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous answer.

Comment thread src/checks.jl Resolved
Comment thread NEWS.md Resolved
Comment thread test/test_checks.jl Resolved
Comment thread test/test_checks.jl Resolved

@JulStraus JulStraus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. However, do not forget that once #108 is merged, you must merge main into this branch (linear history).

@espenbodal
espenbodal merged commit e0268c8 into main Oct 28, 2026
5 checks passed
@espenbodal
espenbodal deleted the enhance/check_resources branch October 28, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check_resource and check_resources hooks

3 participants