Check for extraneous or mis-categorized input parameters#647
Check for extraneous or mis-categorized input parameters#647johnjasa merged 32 commits intoNatLabRockies:developfrom
Conversation
genevievestarke
left a comment
There was a problem hiding this comment.
This is fantastic functionality, @elenya-grant !! I love the tests!
| "dispatch_rule_parameters": {"commodity": "electricity", "commodity_rate_units": "kW"}, | ||
| }, | ||
| } | ||
| # 3: check when an unused parameter is under shared_parameters |
There was a problem hiding this comment.
Can we update this doc string?
|
@elenya-grant, based on our previous conversation, I cleaned up the logic so everything is much flatter and with simplified control flow and implementing the additional checks from your notes. All of your core logic was sound, and so I just added a single case to I think the one piece that's missing for resolving #251 is to update the default |
|
@RHammond2 - Thank you for cleaning it up and adding another test! I appreciate it! Go team! In response to this:
Personally, I still like the usage of Granted, if the larger team agrees with updating the strict setting to False and updating the calls to |
|
@elenya-grant, that makes sense to me, and IIRC we were aiming to make |
johnjasa
left a comment
There was a problem hiding this comment.
I love this PR and I'm so glad this is getting addressed! The collaborative nature that you achieved this is just fantastic. @elenya-grant, great movement on the ideas and implementation, and @RHammond2, thanks for streamlining the code so well.
I made a small change to include the tech_config_fpath to the method so the error message can include the file that a user would need to change. In working with some new users recently, I found that our error messages could generally point towards the exact files and sections they'd need to modify, so I hope this change is helpful to those folks.
Great stuff!
|
Converter files where
Not sure if these should be updated to |
Thanks so much for adding the additional error handling, @johnjasa, I completely missed that aspect when thinking through the streamlining! |
kbrunik
left a comment
There was a problem hiding this comment.
Looks great to me! Thank you for updating the other models that were unnecessarily using strict = False.
One note for other folks who might look at this, strict = False is necessary for the ECOElectrolyzerPerformanceModelConfig because it's inherited and fully reinstantiated by WOMBATModelConfig and will throw an error because WOMBATModelConfig requires extra inputs but appear extraneous to the ECOElectrolyzerPerformanceModelConfig.
It seems like there's some weird stuff going on with the CI, @RHammond2, it looks like it's the windows tests. Any ideas?
Check for extraneous or mis-categorized input parameters
HUGE THANKS TO @RHammond2 FOR HELPING WITH THIS PR SO MUCH!
This PR introduces a route to resolving Issue #251. In this PR - the user-provided technology configuration is compared against the
configattributes of the models that make up that technology after the open-mdao problem has been setup. This is only checked for technologies that have a defined control strategy or dispatch rule set (more than just a cost model and/or a performance model). This is because these are the only cases where models should be using astrict=Falsewhen creating the config attribute (currently, this basically only applies to storage cost, performance, and control models).This will throw an error if the user-provided technology configuration has:
The general methodology/idea is to:
configattribute of each model for that technologyshared_parameterssectionA follow-on PR will expand the functionality of the
check_inputsmethod to be applied for all technologies (not just ones with a dispatch_rule_set or control_strategy). This would likely requiring adding in special handling for finance models, combined cost and finance models, and require updating more input files (which is why it'd be a separate PR).Section 1: Type of Contribution
Section 2: Draft PR Checklist
TODO:
Type of Reviewer Feedback Requested (on Draft PR)
Structural feedback:
Implementation feedback:
Other feedback:
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 3: Related Issues
This is intended to resolve, or at least mostly resolve Issue #251. Likely will need a follow-on PR for Issue #251 to be fully resolved.
Section 4: Impacted Areas of the Software
Section 4.1: New Files
N/A
Section 4.2: Modified Files
h2integrate/core/dict_utils.pycheck_inputs(): new method that checks for extra or mis-categorized inputsh2integrate/core/h2integrate_model.py:setup(): added call tocheck_inputsfunctioncreate_technology_models(): had to update subgroup naming in the handling of combined performance/cost model creation. This was most visible for the usage of theHOPPComponentas the performance & cost model and having a dispatch rule set. TheHOPPComponentwas being named as the tech name (hopp), not the model name (HOPPComponent), which was causing issues in thecheck_inputs()method.h2integrate/core/test/test_utilities.pytest_check_inputs(): tests that the check_inputs method works as expectedcreate_om_problem(): new method that is used intest_check_inputsh2integrate/core/test/inputs/no_duplicates.yaml: addeddemand_profileunder the battery performance parameters so that the battery model can be instantiated properlyExamples that need fixed tech configs:
01_onshore_steel_mn: updated combiner, battery, h2_storage02_texas_ammonia: updated combiner, battery, h2_storage12_ammonia_synloop: updated combiner, battery, h2_storage18_pyomo_heuristic_dispatch: updated battery30_pyomo_optimized_dispatch: updated battery09_co2/direct_ocean_capture: updated hopp, combiner, and battery09_co2/ocean_alkalinity_enhancement: updated batteryThe fact that these tech config files needed to be updated is proof that the added functionality works as intended (yay!).
Section 5: Additional Supporting Information
Section 6: Test Results, if applicable
Section 7 (Optional): New Model Checklist
docs/developer_guide/coding_guidelines.mdattrsclass to define theConfigto load in attributes for the modelBaseConfigorCostModelBaseConfiginitialize()method,setup()method,compute()methodCostModelBaseClasssupported_models.pycreate_financial_modelinh2integrate_model.pytest_all_examples.pydocs/user_guide/model_overview.mddocs/section<model_name>.mdis added to the_toc.yml