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 model validator for pyaro config and ColocatedData #1358

Merged
merged 6 commits into from
Oct 1, 2024

Conversation

lewisblake
Copy link
Member

@lewisblake lewisblake commented Oct 1, 2024

Change Summary

Fix the pyaro config model validator, which had been raising warning and was never really implemented correctly before. Also fix the ColocatedData model_validator

Related issue number

Close #1349

Checklist

  • Start with a draft-PR
  • The PR title is a good summary of the changes
  • PR is set to AeroTools and a tentative milestone
  • Documentation reflects the changes where applicable
  • Tests for the changes exist where applicable
  • Tests pass locally
  • Tests pass on CI
  • At least 1 reviewer is selected
  • Make PR ready to review

@lewisblake lewisblake changed the title Fix pyaro config model validator Fix model validator for pyaro config and ColocatedData Oct 1, 2024
@lewisblake lewisblake added this to the m2024-10 milestone Oct 1, 2024
Copy link

codecov bot commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 76.92308% with 6 lines in your changes missing coverage. Please review.

Project coverage is 78.84%. Comparing base (c4ddcfc) to head (af3a797).
Report is 7 commits behind head on main-dev.

Files with missing lines Patch % Lines
pyaerocom/colocation/colocation_setup.py 57.14% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main-dev    #1358   +/-   ##
=========================================
  Coverage     78.83%   78.84%           
=========================================
  Files           136      136           
  Lines         20788    20790    +2     
=========================================
+ Hits          16389    16392    +3     
+ Misses         4399     4398    -1     
Flag Coverage Δ
unittests 78.84% <76.92%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@lewisblake lewisblake marked this pull request as ready for review October 1, 2024 12:16
pyaerocom/colocation/colocated_data.py Outdated Show resolved Hide resolved
"Invalid data filepath str, must point to a .nc file"
)
if not self.data.endswith("nc"):
raise ValueError("Invalid data filepath str, must point to a .nc file")
self.open(self.data)
elif isinstance(self.data, xr.DataArray):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these can be flipped to reduce nesting: if isinstance(ndarray) -> make_DataArray; then ensure_correct_dimensions.

This would also simplify ensure_correct_dimensions to not have to handle ndarray

pyaerocom/colocation/colocation_setup.py Outdated Show resolved Hide resolved
"Invalid data filepath str, must point to a .nc file"
)
if not self.data.endswith("nc"):
raise ValueError("Invalid data filepath str, must point to a .nc file")
self.open(self.data)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is currently not clear that read files are dimension validated without going two function calls deep, which makes this look like a bug without being one. Maybe it can be made clearer?

Copy link
Collaborator

@thorbjoernl thorbjoernl left a comment

Choose a reason for hiding this comment

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

LGTM

@lewisblake lewisblake merged commit dcdcc3f into main-dev Oct 1, 2024
7 of 8 checks passed
@lewisblake lewisblake deleted the fix-pydantic-model-validator branch October 2, 2024 07:38
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.

Clean up pydantic model validators
2 participants