Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add a pydantic model which encapsulates required BMI time meta data #22

Merged
merged 5 commits into from
Apr 24, 2024

Conversation

hellkite500
Copy link
Owner

This model can be used in BMI implementations to store related time components and validate the BMI constraints of these meta data.

@hellkite500 hellkite500 requested review from taddyb and aaraney April 23, 2024 21:47
Copy link
Collaborator

@aaraney aaraney left a comment

Choose a reason for hiding this comment

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

Overall, looks good! I think we can improve on the one pydantic model by using typing.Literals instead of a custom validator. LMK if I wasn't clear about that or you would like to provide an example.

# TODO extracted from looking throug the xml files
# https://docs.unidata.ucar.edu/udunits/current/#Database
# need to verify this is a complete set...
valid_units = ["s", "sec", "second", "seconds",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would instead make this into a typing.Literal that can be used here or else where. Then there is also no need for this validator, since pydantic will handle it for you.

bmi_sdk/tests/test_bmi_time.py Outdated Show resolved Hide resolved
bmi_sdk/tests/test_bmi_time.py Outdated Show resolved Hide resolved
@aaraney
Copy link
Collaborator

aaraney commented Apr 24, 2024

@hellkite500, just as a heads up, I changed valid_units to a Literal and for better or worse formatted the codebase using black. It is at least split up in the history.

Copy link
Collaborator

@taddyb taddyb left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Nice addition with the Literals

@hellkite500 hellkite500 merged commit 9681a65 into main Apr 24, 2024
4 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants