Skip to content
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

feat: value_unit_pair module #95

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

aaraney
Copy link
Member

@aaraney aaraney commented Feb 6, 2024

Add ValueUnitPair and ListUnitPair classes. The former captures the concept of a value and a unit (i.e. 42[meters]) while the latter is an extension of the concept but for a list of values.

Why do we need this? BMI modules: soil freeze thaw, soil moisture profile, lgar, and CFE all use this format in their configuration files. These classes provide a way for capturing the expressed concept as pydantic models. This will enable adding the aforementioned modules to ngen.config.

Notes

  • There are a few PRs that I am in the process of staging that will result in a ngen.config version bump, but this alone does not constitute a version bump.

@aaraney aaraney requested a review from hellkite500 February 6, 2024 19:20
@aaraney aaraney added the ngen.config Related to ngen.config package label Feb 6, 2024
U = TypeVar("U")


_VAL_UNIT_RE = re.compile(r"(.*)\[(.*)\]")
Copy link
Contributor

Choose a reason for hiding this comment

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

Not that I think we should now, but may want to consider more restrictive regex here in the future...especially considering captures which have spaces, non-standard characters, ect. This may be impossible to generalize and too far out of scope though -- just a passing thought.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I agree. I didn't and don't know at this point in time what appropriate constraints to enforce here, so I left it a little open. My thinking was we could always refine this if needed.

Add `ValueUnitPair` and `ListUnitPair` classes. The former captures the
concept of a value and a unit (i.e. `42[meters]`) while the latter
is an extension of the concept but for a list of values.

Why do we need this? BMI modules: soil freeze thaw, soil moisture
profile, lgar, and CFE all use this format in their configuration files.
These classes provide a way for capturing the expressed concept as
pydantic models. This will enable adding the aforementioned modules to
`ngen.config`.
@hellkite500 hellkite500 merged commit 6c9d2c8 into NOAA-OWP:master Mar 7, 2024
13 checks passed
@aaraney
Copy link
Member Author

aaraney commented Mar 7, 2024

Thanks, @hellkite500!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ngen.config Related to ngen.config package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants