-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
@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. |
assert ( | ||
len(title.encode()) <= 256 | ||
), "`title` must be less that 256 bytes in length" | ||
data["subcat"] = title |
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 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...)
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, 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`" |
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.
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) |
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.
Can we warn if NGEN configs are marked with the standalone flag?
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, 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?
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 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.
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.
Just pushed up this feature.
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 see it 👀
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.
Ooooops, you right. I put a warning somewhere else but not here. Just added it. My b.
Initial structures for parsing
topmodel
configuration files. Still a few things to sort so it is more compliant withngen.init_config
, but this is a good start.