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

Validation of User Configuration #28

Merged
8 commits merged into from
Sep 20, 2024
Merged

Validation of User Configuration #28

8 commits merged into from
Sep 20, 2024

Conversation

pgierz
Copy link
Member

@pgierz pgierz commented Aug 7, 2024

This adds a collection of validators that can be run against the user supplied dictionaries to check for errors.

Closes #27

@pgierz
Copy link
Member Author

pgierz commented Aug 8, 2024

This looks promising for capturing user errors, just need some nice formatting:

        if "rules" in data:
            if not RULES_VALIDATOR.validate({"rules": data["rules"]}):
>               raise ValueError(RULES_VALIDATOR.errors)
E               ValueError: {'rules': [{0: [{'description': ['unknown field'], 'enabled': ['unknown field'], 'pipelines': ['unknown field']}], 1: [{'cmor_units': ['unknown field'], 'description': ['unknown field'], 'enabled': ['unknown field'], 'pipelines': ['unknown field']}], 2: [{'cmor_variable': ['null value not allowed'], 'enabled': ['unknown field']}], 3: [{'cmor_variable': ['null value not allowed'], 'pipelines': ['unknown field']}]}]}

@pgierz pgierz requested review from siligam and mandresm August 8, 2024 11:03
Copy link
Member Author

@pgierz pgierz left a comment

Choose a reason for hiding this comment

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

There is one part I am not sure about that @siligam should check.

Comment on lines +83 to +84
# FIXME(PS): How is it currently defined?
"model_units": {"type": "string", "required": False},
Copy link
Member Author

Choose a reason for hiding this comment

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

@siligam: This still needs to be added correctly for units.py. I wasn't sure how you had designed it.

Copy link
Contributor

Choose a reason for hiding this comment

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

@pgierz "model_units" is referred as "source_units" in units.py. It is a optional parameter. If it is not provided, it reads the model units from xarray dataset. At times, user prefers to use some other unit instead of units from xarray dataset. In this case, "source_units" takes precedence if provided.
The setting "model_units" : {"required": False} is apt.

@pgierz pgierz marked this pull request as ready for review August 8, 2024 11:05
@siligam siligam closed this pull request by merging all changes into main in 587820f Sep 20, 2024
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.

Schema-Checking for Configuration File
2 participants