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

Compatiblity with CFTime #238

Closed
wants to merge 3 commits into from

Conversation

rabernat
Copy link

@rabernat rabernat commented Nov 5, 2020

I am trying to catalog climate model data stored in Zarr format on Google Cloud / AWS using STAC. My approach is to create a STAC collection for each Zarr dataset and link to the Zarr data using collection-level assets (see related discussion @ radiantearth/stac-spec#781).

I have hit a tiny snag with datetimes. I need to populate temporal_extent for the collections. I get this by reading the dataset's time range. The times are encoded using the CF Conventions for time coordinates. In python, CF times are implemented by the cftime package. cftime provides a (mostly) duck-type compatible with datetime. However, cftime has no .tzinfo attribute.

This tiny change allows pystac to work with cftime datetimes.

I have not added a test because I didn't want to add cftime to the dependencies. One could possibly use a mock to test this feature. Or we could merge this tiny change with no test. I'll follow whatever path the devs recommend.

cc @charlesbluca

@codecov-io
Copy link

codecov-io commented Nov 5, 2020

Codecov Report

Merging #238 into develop will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #238   +/-   ##
========================================
  Coverage    93.73%   93.73%           
========================================
  Files           30       30           
  Lines         3749     3749           
========================================
  Hits          3514     3514           
  Misses         235      235           
Impacted Files Coverage Δ
pystac/utils.py 97.70% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50c6ab4...17743b3. Read the comment docs.

@rabernat
Copy link
Author

Could the maintainers (maybe @lossyrob) let me know whether this PR might be acceptable. I'd be happy to make any changes required.

Copy link
Member

@lossyrob lossyrob left a comment

Choose a reason for hiding this comment

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

@rabernat apologies for the delay in review.

The change looks great, however can you provide a unit test that demostrates the failure case when this change is not in place/succeeds with this change? Thanks!

@rabernat
Copy link
Author

The change looks great, however can you provide a unit test that demostrates the failure case when this change is not in place/succeeds with this change?

Sure. Would you prefer I add cftime as a test dependency or that I use some kind of mock / monkeypatch to datetime?

@lossyrob
Copy link
Member

I think the mock/monkeypatch version would work, with a comment pointing at the specific cftime class it is mimicking in case API changes down the road. Thanks!

@rabernat
Copy link
Author

After thinking this through, I decided it made more sense to fix this in cftime, rather than pystac. See Unidata/cftime#209. But thanks for considering this.

@rabernat rabernat closed this Nov 16, 2020
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.

3 participants