generated from NOAA-OWP/owp-open-source-project-template
-
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e3c93ae
Fix typo in Formulation, params, field constrains. fixes #32.
aaraney 9afadf5
add newline to end of file.
aaraney b2cc98c
Give calibration strategy model's strategy field defaults. fixes #33
aaraney 28f88f5
test that ngen strategies are constructed with correct default strategy
aaraney 0aa016f
set default stategy
aaraney ec55543
Formulation model_name's are now Literals. This is required for disri…
aaraney 1f31884
fix merge conflict
aaraney 4c968d7
update tests
aaraney 4821627
add model_name literal consts to SLOTH and PET
aaraney e0058a9
bmi multi test data needed model_type_name = 'BMIMulti'
aaraney 33c434a
add missing Literal import
aaraney 7582871
formulation types are now discriminated using their name and model_ty…
aaraney 14951bb
multibmi's model_name field is an unconstrained str
aaraney 904c2ca
add model_type_name and name params to test fixtures
aaraney a7aca5f
add formulation tests
aaraney 98a6372
re-add model_type_name alias def
aaraney 3d6a8da
update changelog
aaraney 8befaa0
bump ngen.config version 0.1.8 -> 0.1.9
aaraney 13d9d57
update changelog
aaraney 9542f32
revert model_type_name
aaraney 9847a78
if no modules or model name are provided, model name is empty string
aaraney fe0e5a3
bump ngen.config version 0.2.0 -> 0.2.1
aaraney 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 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 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 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pytest | ||
from ngen.cal.ngen import NgenExplicit, NgenIndependent, NgenUniform, NgenStrategy | ||
|
||
|
||
def test_NgenExplicit_strategy_default_value(): | ||
# construct object without validation. | ||
o = NgenExplicit.construct() | ||
assert o.strategy == NgenStrategy.explicit | ||
|
||
|
||
def test_NgenIndependent_strategy_default_value(): | ||
# construct object without validation. | ||
o = NgenIndependent.construct() | ||
assert o.strategy == NgenStrategy.independent | ||
|
||
def test_NgenUniform_strategy_default_value(): | ||
# construct object without validation. | ||
o = NgenUniform.construct() | ||
assert o.strategy == NgenStrategy.uniform |
This file contains 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. That's fine with me. Good catch |
||
"main_output_variable": "Q_OUT", | ||
"init_config": "", | ||
"allow_exceed_end_time": false, | ||
|
Oops, something went wrong.
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.
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 optionalNone
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 toNone
. I guess in a perfect world, we would create a constant, sayCOMPUTED
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.