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: add topmodel init_config models #175

Merged
merged 2 commits into from
Aug 28, 2024
Merged

Conversation

aaraney
Copy link
Member

@aaraney aaraney commented Aug 23, 2024

Initial structures for parsing topmodel configuration files. Still a few things to sort so it is more compliant with ngen.init_config, but this is a good start.

@aaraney
Copy link
Member Author

aaraney commented Aug 26, 2024

@hellkite500, there are a few assumptions that ive made here that we might want to change. In either case, this is ready for a first round of review.

Comment on lines 103 to 154
assert (
len(title.encode()) <= 256
), "`title` must be less that 256 bytes in length"
data["subcat"] = title
Copy link
Member

Choose a reason for hiding this comment

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

I would be inclined to relax this to a warning and simply truncate to 255 (to allow \0 in the c string when read by the code there...)

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 get what you mean. Lets meet in the middle and error if its >255. I would rather fail here if someone is using this for validation purposes and they are being really pedantic about the meaning of validation (never been me before 👀).

data["lnaotb"] = float(distarea_lnaotb[1])

num_channels_str = reader.readline()
assert distarea_lnaotb_str != "", "missing `num_channels`"
Copy link
Member

Choose a reason for hiding this comment

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

Wrong variable in check here, should be num channels

@validator("stand_alone", pre=True)
@classmethod
def _coerce_stand_along(cls, value: str | int):
return int(value)
Copy link
Member

Choose a reason for hiding this comment

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

Can we warn if NGEN configs are marked with the standalone flag?

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 think that's fair. I'd left it this way originally as I was implementing the bare minimum parser for NextGen. I'll go back and add the functionality to support more complex configuration files.

I think it's probably worth maintaining the complexity of a more complex parser and model for this module in particular. I envision TOPMODEL might be a candidate bmi module for a layered configuration in the future. What are your thoughts, @hellkite500?

Copy link
Member

Choose a reason for hiding this comment

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

I generally agree. And I think if we are building ngen specific configuration and validation, we should at least provide warnings of incompatible instances when we can.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just pushed up this feature.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see it 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooooops, you right. I put a warning somewhere else but not here. Just added it. My b.

@aaraney aaraney merged commit 0260868 into NOAA-OWP:master Aug 28, 2024
13 checks passed
@aaraney aaraney deleted the topmodel branch August 28, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ngen.config Related to ngen.config package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants