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

fix: backwards compatibility of NWMRequest #511

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

aaraney
Copy link
Member

@aaraney aaraney commented Jan 30, 2024

Fix backwards compatible handling of NWMRequest config_data_id initializer argument.

dmod.communication -- 0.16.2

Changes

  • Fix backwards compatible handling of NWMRequest config_data_id initializer argument.

@@ -51,8 +51,9 @@ def __init__(
super().__init__(**data)
else:
data["request_body"] = dict()
nwm_inner_request_body = {"config_data_id": config_data_id}
data["request_body"]["nwm"] = nwm_inner_request_body
data["request_body"]["nwm"] = data["model"]["nwm"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Either this or the unit tests are wrong - looks like model isn't coming in through data.

Copy link
Member Author

Choose a reason for hiding this comment

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

@christophertubbs, nice catch, I just fixed it.

@aaraney aaraney force-pushed the fix-nwm-request branch 2 times, most recently from ecbc6c0 to ed48107 Compare January 30, 2024 20:36
Copy link
Contributor

@christophertubbs christophertubbs left a comment

Choose a reason for hiding this comment

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

Looks good.

Stylistic opinion:

Using an approach like:

if "request_body" not in data:
    if "model" in data:
        request_body = data["model"][self.get_model_name()]
    else:
        request_body = {}

    if config_data_id is not None:
        request_body['config_data_id'] = config_data_id

    data['request_body'] = {
        self.get_model_name(): request_body
    }

super().__init__(**data)

will have a single terminal point instead of two and might be a little easier to step through and predict. That's not important here since it's not exactly performing the most convoluted operation, but it is something that caught my eye.

@christophertubbs christophertubbs merged commit e99e180 into NOAA-OWP:master Jan 30, 2024
4 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants