-
Notifications
You must be signed in to change notification settings - Fork 12
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
Fix minor bugs with default values and specificity in ngen.cal and ngen.config #34
Conversation
It looks like by fixing the typo in |
So, the issue is in the |
The multi BMI should be constant at the top level, and the sub modules would be constant in the recursive modules under there |
So it is safe to tie |
For now I think that will work. That was the intent of the original implementation at least... |
Just so we are 1000% on the same page, this means that all |
As long as that only applies to the container, not the sub formulations, then I don't see a problem with that. (though we can decide if it should be BMIMulti or MultiBMI...haha) |
@robertbartel was having some related issues over here which made me revisit this.
In re-reading this, @hellkite500, I think I was being a little pedantic in my use of the word 'constant'. To re-phrase, is it okay to enforce that all |
@aaraney, @hellkite500, I'm only just starting to dig into this, so I may not quite understand everything correctly yet. But ngen-config functionality seems to depend on using specific strings for the E.g., a BMI multi-formulation must be configured with something like this in the realization config file: "model_type_name": "BMIMulti", Based on the first few example realization configs I have looked at after beginning to review this (see here), that appears to be a condition that not necessarily followed in practice or in principle, at least in the provided examples. I.e., Additionally, the ngen documentation on BMI formulations in realization configs only indicates that some This probably warrants further design and dependencies discussion, although a verification of my assessments is probably needed first. |
@robertbartel, your assessment is correct. |
@aaraney, I rebased this branch, then fixed a few other non-Literal |
@robertbartel, thanks for the breadcrumbs. Ill have a look to see what changes I might need to make in this PR. |
@robertbartel, I see. This PR predates the |
I added support for |
The tests should fail because of #62. |
The only tests are that failing are because of #62. Ill get in a quick PR to fix that, we can rebase this once that fix is in and re-review. |
…minator purposes.
…pe_name fields Note, during object creation if the `params` field is deserialized (e.g. `params`'s value is a dictionary), the `name` field is required. If `name` *is not* 'bmi_multi', the `model_type_name` field is also required. Neither are required if a concrete known formulation instance is provided.
@@ -22,7 +23,7 @@ class MultiBMI(BMIParams, smart_union=True): | |||
# NOTE this is derived from the list of modules | |||
main_output_variable: Optional[str] | |||
#NOTE aliases don't propagate to subclasses, so we have to repeat the alias | |||
model_name: Optional[str] = Field(alias="model_type_name") | |||
model_name: str = Field(alias="model_type_name") |
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.
Could this still be optional?
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.
I don't think so. In the super class it is a str
. I think the most sensible thing is to either set a default empty string or leave it as is. Thoughts?
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.
well the validator build_model_name
was using the optional None
in order to build the name from the named nested modules. We can set a default empty string ""
but would need to ensure that validator recognizes that and substitutes the built name.
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.
Yeah, this is one of my gripes with pydantic
. There is not a semantic way to signify to the caller that something is computed if it is not provided. The way that we have been doing this in DMOD is to set the default of a non-optional field to None
. I guess in a perfect world, we would create a constant, say COMPUTED
and use that as the default value.
Here, I just went with setting the default value to None
and updated the root validator to always set the model name to something if it is not provided.
@@ -6,7 +6,7 @@ | |||
"name": "bmi_multi", | |||
"params": { | |||
"name": "bmi_multi", | |||
"model_type_name": "NoahOWP_CFE", | |||
"model_type_name": "BMIMulti", |
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.
Should we revert this if "BMIMulti" isn't the required literal now?
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.
That's fine with me. Good catch
Fixes minor issues in cal and config's pydantic model fields. This does not introduce any breaking changes.
fixes #31, #32, #33
Ngen Cal [0.2.1] - 2023-06-24
Changes
ngen.cal
Objective
enum now properly subclassesstr
. This fixes pydantic models' json schemas that useObjective
as a field type. See ngen.cal Objective Enum needs type constraints #31 for impacts.ngen.cal
calibration strategy types:NgenExplicit
,NgenIndependent
, andNgenUniform
, now have defaultstrategy
field values.Ngen Config [0.1.9] - 2023-06-24
Changes
ngen.config
'sFormulation
modelparams
field.Note, during
Formulation
object creation if theparams
field is deserialized (e.g.params
's value is a dictionary), thename
field is required. Ifname
is not 'bmi_multi', themodel_type_name
field is also required. Neither are required if a concrete known formulation instance is provided (see Typo in formulation model constraint #32).Testing
NgenExplicit
,NgenIndependent
, andNgenUniform
strategy
field default value.Checklist
Testing checklist
Target Environment support