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

Rename setup_classes & include creation_date in ExperimentInfo #1344

Merged
merged 10 commits into from
Sep 20, 2024

Conversation

lewisblake
Copy link
Member

@lewisblake lewisblake commented Sep 18, 2024

Change Summary

  • Renamed setupclasses.py to setup_classes.py to follow Python module naming standard of splitting words with underscores
  • Added a creation_date attribute to ExperimentInfo. Defaults to datetime.today().strftime("%Y-%m-%d") but can also be provided if a pyaeroval user wants to modified it.

Related issue number

Close https://github.com/metno/AeroToolsIssues/issues/75

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 added this to the m2024-10 milestone Sep 18, 2024
@lewisblake lewisblake marked this pull request as ready for review September 18, 2024 10:52
Copy link
Member

@heikoklein heikoklein left a comment

Choose a reason for hiding this comment

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

The official interface for using EvalSetup is:
from pyaerocom.aeroval import EvalSetup
Therefore, renaming setupclasses to setup_classes is fine here. It would be good if the test-cases could use the official interface rather than the internal access-path.

The documentation for EvalSetup needs to been fixed:

.. automodule:: pyaerocom.aeroval.setupclasses

Can creation_date have time-resolution e.g. https://stackoverflow.com/questions/10286204/what-is-the-right-json-date-format

pyaerocom/aeroval/setup_classes.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Sep 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.97%. Comparing base (4a7bece) to head (931e6ad).
Report is 16 commits behind head on main-dev.

Additional details and impacted files
@@            Coverage Diff            @@
##           main-dev    #1344   +/-   ##
=========================================
  Coverage     78.97%   78.97%           
=========================================
  Files           136      136           
  Lines         20815    20817    +2     
=========================================
+ Hits          16438    16440    +2     
  Misses         4377     4377           
Flag Coverage Δ
unittests 78.97% <100.00%> (+<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.

Copy link
Member

@heikoklein heikoklein left a comment

Choose a reason for hiding this comment

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

Please use the json-datetime format and utc.
Please use the official way to import EvalSetup where possible.

tests/aeroval/test_aeroval_HIGHLEV.py Outdated Show resolved Hide resolved
tests/aeroval/test_experiment_output.py Outdated Show resolved Hide resolved
tests/aeroval/test_experiment_processor.py Outdated Show resolved Hide resolved
tests/aeroval/test_helpers.py Outdated Show resolved Hide resolved
tests/aeroval/test_modelmaps_engine.py Outdated Show resolved Hide resolved
tests/aeroval/test_setup_classes.py Show resolved Hide resolved
Copy link
Member

@heikoklein heikoklein left a comment

Choose a reason for hiding this comment

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

Thanks.

I just got a small idea on how to hide the setup_classes in user/test-space even more, not crucial, so I approve the PR and leave it to you if you want to change or just merge.

@@ -113,7 +113,7 @@ def test_ExperimentOutput():
def test_ExperimentOutput_error():
with pytest.raises(ValueError) as e:
ExperimentOutput(None)
assert str(e.value) == "need instance of <class 'pyaerocom.aeroval.setupclasses.EvalSetup'>"
assert str(e.value) == "need instance of <class 'pyaerocom.aeroval.setup_classes.EvalSetup'>"
Copy link
Member

Choose a reason for hiding this comment

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

To avoid hardcoding class-pathes, it could be written as:

f"need instance of {EvalSetup}"

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this ValueError.value comes from

raise ValueError(f"need instance of {self._type}")

so it would be a little tricky to change just in this case.

Copy link
Member

Choose a reason for hiding this comment

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

I just meant replace

assert str(e.value) == "need instance of <class 'pyaerocom.aeroval.setupclasses.EvalSetup'>"

with

assert str(e.value) == f"need instance of {EvalSetup}"

This would not need any changes to _lowlevel_helpers.py. The string expansion of {self._type} and {class} is the the same.

@lewisblake lewisblake merged commit 4ef307b into main-dev Sep 20, 2024
8 checks passed
@lewisblake lewisblake deleted the creation-date-75 branch September 20, 2024 13:11
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