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

Feat io tests #21

Merged
merged 39 commits into from
Nov 21, 2023
Merged

Feat io tests #21

merged 39 commits into from
Nov 21, 2023

Conversation

sphamba
Copy link
Collaborator

@sphamba sphamba commented Oct 30, 2023

Summary

  • add granule data as submodule
  • add tests for io
    • checks → 100%
    • fliter → 100%
    • info → all used functions
    • find: _get_all_daily_filepaths for local, pps and ges disc

Note: coverage for io/ges_disc and io/pps will be increased by testing io/download

@sphamba sphamba requested a review from ghiggi November 7, 2023 09:08
@sphamba sphamba marked this pull request as ready for review November 7, 2023 09:08
Copy link
Owner

@ghiggi ghiggi left a comment

Choose a reason for hiding this comment

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

I commented a couple of test units that can be improved and simplified ;)

gpm_api/tests/conftest.py Show resolved Hide resolved
gpm_api/tests/test_dataset/test_granule.py Outdated Show resolved Hide resolved
gpm_api/tests/test_dataset/test_granule.py Outdated Show resolved Hide resolved
gpm_api/tests/test_dataset/test_granule.py Outdated Show resolved Hide resolved
gpm_api/tests/test_dataset/test_granule.py Outdated Show resolved Hide resolved
gpm_api/tests/test_io/test_find.py Outdated Show resolved Hide resolved
gpm_api/tests/test_io/test_find.py Outdated Show resolved Hide resolved
gpm_api/tests/test_io/test_find.py Outdated Show resolved Hide resolved
gpm_api/tests/test_io/test_info.py Outdated Show resolved Hide resolved
gpm_api/tests/test_io/test_info.py Outdated Show resolved Hide resolved
@sphamba sphamba requested a review from ghiggi November 16, 2023 15:00
"_get_info_from_filename",
autospec=True,
return_value={
"product": "2A-CLIM",
Copy link
Owner

Choose a reason for hiding this comment

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

I am not entirely sure I grasp correctly what it's going on here.
For whatever product below is passed in the download function below, _get_info_from_filename will return this dummy inexistent product information? Maybe we should mock this function and ensure that the result varies depending on the product info in the product.yaml file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, the same information is returned regardless of the filename. It seems the tests in this class were written just to make sure than the whole download_archive function is executed without issues, but there are no actual checks.

Copy link
Owner

@ghiggi ghiggi Nov 21, 2023

Choose a reason for hiding this comment

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

Ok. Can you just add a short comment explaining that for the future me?

gpm_api/io/ges_disc.py Show resolved Hide resolved
Copy link
Owner

@ghiggi ghiggi 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 all the work ! We can discuss the last points in person this week maybe?
Also quickly resolve these issues ... https://app.codacy.com/gh/ghiggi/gpm_api/pullRequest?prid=12944041

For me it's fine then fine to merge this and then address the remaining issues in a separate PR ...
I see that CodeCov does not report anymore the coverage statistics ... and also Coveralls shows some issues.
So maybe let's merge, resolve the CI issues and then implement the last tests to the io module

gpm_api/io/find.py Show resolved Hide resolved
@@ -94,6 +103,7 @@ def remote_filepaths() -> Dict[str, Dict[str, Any]]:
"start_time": datetime.datetime(2020, 7, 5, 17, 0, 44),
"end_time": datetime.datetime(2020, 7, 5, 18, 33, 17),
"version": 7,
"granule_id": 36092,
Copy link
Owner

Choose a reason for hiding this comment

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

Do you think this should be refactor or extended? Or generated from specific functions ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Each entry has a little difference to test various things. Maybe the entries could be indeed templated to look less copy pasted :)

Copy link
Owner

@ghiggi ghiggi Nov 21, 2023

Choose a reason for hiding this comment

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

Note this down @sphamba and let's improve this at later stage ;)

monkeypatch.setattr(conventions, "set_coordinates", mock_set_coordinates)

# Return a default dataset
da = xr.DataArray(np.random.rand(1, 1), dims=("other", "along_track"))
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe we should define here also a dataset for Grid data like IMERG that has ("time", "lat", "lon") columns?
And return the dataset according to the product?
Right now we test only for Orbit data ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The _prepare_test_finalize_dataset is not the only way I generate datasets for testing. Other dims are tested in test_finalize_dataset_reshaping, and it seemed to me that the rest of finalize did not depend on these dimensions. Tell me if you would still like to have the rest of finalize tested on Grid data

Copy link
Owner

@ghiggi ghiggi Nov 21, 2023

Choose a reason for hiding this comment

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

Maybe it's worth still do this effort and have a test unit checking that the finalize_dataset functions works both from Orbit and Grid object.
So that if in future someone will enhance/modify the function, we ensure that the objects are processed correctly.

gpm_api/tests/test_io/test_data_integrity.py Show resolved Hide resolved
@sphamba sphamba merged commit bc11c99 into ghiggi:main Nov 21, 2023
10 of 11 checks passed
@sphamba sphamba deleted the feat-io-tests branch November 21, 2023 20:44
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