Repository navigation
Register models with a @register decorator instead of a hardcoded dictionary - #902
Merged
johnjasa merged 5 commits intoOct 7, 2026
Merged
Conversation
johnjasa
marked this pull request as draft
October 5, 2026 19:28
johnjasa
marked this pull request as ready for review
October 5, 2026 19:28
RHammond2
approved these changes
Oct 6, 2026
| text = path.read_text(encoding="utf-8") | ||
| if "@register" not in text or "test" in path.relative_to(_PACKAGE_DIR).parts: | ||
| continue | ||
| module = ".".join(path.relative_to(_PACKAGE_DIR.parent).with_suffix("").parts) |
Collaborator
There was a problem hiding this comment.
Love to see some slick Path logic!
johnjasa
enabled auto-merge
October 7, 2026 21:51
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Register models with a
@registerdecorator instead of a hardcoded dictionaryModels are now registered by decorating the class, so adding a model no longer requires editing
supported_models.py. Model modules are still imported lazily.registermarker decorator with optionalname,no_cost, andno_replacement_schedulearguments.supported_models.pynow buildssupported_models,no_cost_models, andno_replacement_schedule_modelsby scanning the package source for@register. Classes are imported on first lookup, and duplicate names raise aValueError.Section 1: Type of Contribution
Section 2: Draft PR Checklist
TODO:
N/A
Type of Reviewer Feedback Requested (on Draft PR)
Structural feedback: N/A
Implementation feedback: N/A
Other feedback: N/A
Section 3: General PR Checklist
docs/files are up-to-date, or added when necessaryCHANGELOG.md"A complete thought. [PR XYZ]((https://github.com/NatLabRockies/H2Integrate/pull/XYZ)", where
XYZshould be replaced with the actual number.Section 4: Related Issues
Resolves #901
Section 5: Impacted Areas of the Software
Section 5.1: New Files
h2integrate/core/test/test_supported_models.pynameargument, and the flag sets.Section 5.2: Modified Files
h2integrate/core/supported_models.pyregisterdecorator and a source scan (275 to 72 lines).h2integrate/{control,converters,demand,feedstocks,finances,resource,storage,transporters}/**/*.py(103 files)@registerto each previously registered model class.docs/generate_model_overview.pypyproject.tomlE501ignore forsupported_models.py, which no longer has long lines..github/PULL_REQUEST_TEMPLATE.md@register.Section 6: Additional Supporting Information
import h2integrate.@registermust be at column 0, directly above theclassline, with literal arguments.Section 7: Test Results, if applicable
Runs locally well!
Section 8 (Optional): New Model Checklist
N/A