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

Improve handling of client dataset creation attempt without domain #537

Merged
merged 3 commits into from
Mar 12, 2024

Conversation

robertbartel
Copy link
Contributor

Improve the client's behavior when it attempts to create a dataset but no data domain is defined/provided. Previously, an error was raised. Now, a response object will be returned by the relevant function to the client and displayed, indicating that the attempt failed and giving some information on why. E.g., attempting something like this:

python -m dmod.client dataset create --format NGEN_REALIZATION_CONFIG test_composite_1 config

will now yield something like this:

{
   "message" : "Could not inflate keyword params to object due to RuntimeError - Cannot create DataDomain without at least one finite continuous or discrete restriction",
   "reason" : "No Dataset Domain Provided",
   "success" : false
}

This relates to #531, although strictly speaking this was not a bug preventing valid dataset creation (only an obscuring of an invalid attempt to create one).

@robertbartel robertbartel added enhancement New feature or request maas MaaS Workstream labels Mar 7, 2024
Updating client logic to respond with more informative messages
indicating the problem, rather than simply throwing an error, if an
attempt is made to create a dataset without providing a valid domain.
@robertbartel
Copy link
Contributor Author

FYI, @aaraney and @hellkite500, I've resolved the previous test failures by merging in recent upstream stuff.

Copy link
Member

@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.

Thanks, @robertbartel! Just one comment. Should be good to go after that.

@@ -64,6 +64,62 @@ def __init__(self, client_config: ClientConfig, bypass_request_service: bool = F

self._auth_client: AuthClient = AuthClient(transport_client=self._get_transport_client())

def _extract_dataset_domain(self, **kwargs) -> DataDomain:
Copy link
Member

Choose a reason for hiding this comment

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

Thoughts on making this a staticmethod just to make it clear that it does not modify the state of the instance, but makes sense to have it here for cohesion reasons?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, it's an interesting thought exercise ... I didn't really intend for things to make it possible to call this outside an instance; I just wanted to tidy up the code a bit. On the other hand, aside from implying no state changes, it's probably slightly more performant.

Rather than fall all the way down the rabbit hole, I went ahead and made the change.

Copy link
Member

@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.

LGTM, thanks @robertbartel!

@aaraney
Copy link
Member

aaraney commented Mar 12, 2024

Merge at will

@robertbartel robertbartel merged commit 565c722 into NOAA-OWP:master Mar 12, 2024
8 checks passed
@robertbartel robertbartel deleted the f/client_domain_fix branch March 12, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request maas MaaS Workstream
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants