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 error message in variable definition check #2313

Merged
merged 6 commits into from
Feb 12, 2024

Conversation

enekomartinmartinez
Copy link
Contributor

@enekomartinmartinez enekomartinmartinez commented Jan 30, 2024

Description

This PR should correct the bug of not correctly raising the error message in the variable check of the recipe.

Closes #2312

Link to documentation:


Before you get started

Checklist

It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.


To help with the number pull requests:

Copy link

codecov bot commented Jan 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c8635a8) 93.74% compared to head (27a9d03) 93.78%.
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2313      +/-   ##
==========================================
+ Coverage   93.74%   93.78%   +0.03%     
==========================================
  Files         238      238              
  Lines       13153    13153              
==========================================
+ Hits        12330    12335       +5     
+ Misses        823      818       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@enekomartinmartinez
Copy link
Contributor Author

I just updated the commit so as not to have the same error with the variable_group. It would be nice to include unity tests for these error messages.

Copy link
Member

@bouweandela bouweandela left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to contribute! Looks good, just a minor suggestion to make the error message even more readable.

esmvalcore/_recipe/check.py Outdated Show resolved Hide resolved
esmvalcore/_recipe/check.py Outdated Show resolved Hide resolved
@bouweandela bouweandela added the bug Something isn't working label Feb 1, 2024
@bouweandela
Copy link
Member

If you'd like to add a unit tests for this, see here for an example of how to write such a test:

def test_invalid_multi_model_ignore_scalar_coords():

@enekomartinmartinez
Copy link
Contributor Author

Thanks for taking the time to contribute! Looks good, just a minor suggestion to make the error message even more readable.

Thanks for the suggestions, I will also update the error message in similar functions to have something more "uniform".

@bouweandela
Copy link
Member

bouweandela commented Feb 5, 2024

Would you still like to add a test, or shall we merge this as-is?

@enekomartinmartinez
Copy link
Contributor Author

enekomartinmartinez commented Feb 6, 2024

Hi @bouweandela I have tried to uniformize the RecipeErrors and tests them for:

Note that there are two errors (currently added tests with xfail) that are not raised:

if 'scripts' not in diagnostic:
raise RecipeError(
"Missing scripts section in diagnostic {}".format(name))

if not script.get('script'):
raise RecipeError(
"No script defined for script {} in diagnostic {}".format(
script_name, name))

This is because the error was raised before by the yamale.validate check.

Therefore, for me, it would make sense to do any of these:

  1. Remove the RecipeErrors that are not raised and convert the test to a yamale.validate errors
    or
  2. Soften the condition for the yamale.validate, setting required=False for those entries in the recipe_schema.yml and let the RecipeError raise later (which I think is more user friendly).

Let me know which one you prefer

@bouweandela
Copy link
Member

I agree that option 2 is more user-friendly. Especially less technical users can get confused by the cryptic error messages coming from Yamale (see e.g. #1080 and #681)

@enekomartinmartinez
Copy link
Contributor Author

@bouweandela, this is already okay and ready to merge by my side. Please, let me know if you find anything else missing!

@bouweandela
Copy link
Member

Would you like to add yourself to the list of authors?

@enekomartinmartinez
Copy link
Contributor Author

Would you like to add yourself to the list of authors?

Done, thank you!

Copy link
Contributor

@valeriupredoi valeriupredoi left a comment

Choose a reason for hiding this comment

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

excellent work, gents 🍻

@valeriupredoi valeriupredoi merged commit 5171ee3 into ESMValGroup:main Feb 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

var has not key 'diagnostic' error when checking var from the recipe
3 participants