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

Switching netcdf3 & netcdf4 filetype detection to file magic 🧙 #64

Merged
merged 2 commits into from
Apr 1, 2024

Conversation

norlandrhagen
Copy link
Collaborator

Copy link

codecov bot commented Mar 28, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 90.48%. Comparing base (2c5be3f) to head (757c571).

Files Patch % Lines
virtualizarr/kerchunk.py 71.42% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #64      +/-   ##
==========================================
+ Coverage   90.29%   90.48%   +0.18%     
==========================================
  Files          14       14              
  Lines         938      946       +8     
==========================================
+ Hits          847      856       +9     
+ Misses         91       90       -1     
Flag Coverage Δ
unittests 90.48% <75.00%> (+0.18%) ⬆️

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.

if dataset.data_model == "NETCDF4":
filetype = "netCDF4"
elif dataset.data_model == "NETCDF3_CLASSIC":
filetype = "netCDF3"
Copy link
Collaborator

@rabernat rabernat Mar 28, 2024

Choose a reason for hiding this comment

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

This function should return an enum, not a string.

Everything in this library should be super strictly typed.

Copy link
Collaborator Author

@norlandrhagen norlandrhagen Mar 28, 2024

Choose a reason for hiding this comment

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

@rabernat Should these be similar to how it's done in pangeo-forge-recipes?, ie.

class FileType(AutoName):
    netcdf3 = auto()
    netcdf4 = auto()
    grib = auto()


...

filetype = FileType("netcdf3")

Copy link
Member

@TomNicholas TomNicholas left a comment

Choose a reason for hiding this comment

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

I think this looks good!

@norlandrhagen
Copy link
Collaborator Author

Sounds good, ready to merge?

@TomNicholas TomNicholas merged commit b58b3ae into main Apr 1, 2024
7 of 8 checks passed
@TomNicholas TomNicholas deleted the netcdf_magic branch April 1, 2024 18:50
@TomNicholas
Copy link
Member

Thanks again @norlandrhagen !

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