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
Add access point to global_attrs to netCDF4FileHandler #1772
Add access point to global_attrs to netCDF4FileHandler #1772
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, just a linting error to fix so far :)
Co-authored-by: Martin Raspaud <martin.raspaud@smhi.se>
Codecov Report
@@ Coverage Diff @@
## main #1772 +/- ##
==========================================
+ Coverage 92.82% 92.91% +0.08%
==========================================
Files 263 265 +2
Lines 38717 39037 +320
==========================================
+ Hits 35940 36272 +332
+ Misses 2777 2765 -12
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think these are my last comments, after that it should be good to merge :)
Co-authored-by: Martin Raspaud <martin.raspaud@smhi.se>
Co-authored-by: Martin Raspaud <martin.raspaud@smhi.se>
Co-authored-by: Martin Raspaud <martin.raspaud@smhi.se>
Co-authored-by: Martin Raspaud <martin.raspaud@smhi.se>
Thanks a lot! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! One more consideration: what do you think about storing the global attributes in a separate dictionary (ex. self._global_attrs = {}
) or as a separate key (ex. self.file_content['/attrs'] = {}
) and have that filled in in the _collect_attrs
method when the file is read. We're already storing all the global attributes in self.file_content
so having another copy wouldn't be that bad. You could have a special _collect_global_attrs
method to do it maybe. Just a thought.
That's also nice idea! But I'd like to see what's going on with the current implementation. Thank you :) |
I'm not sure I understand what you mean. Are you saying you like the current implementation and don't want to change it? |
@djhoese Sorry for the confusion. I don't really have time for this. If someone wants to change the implementation, that's fine. |
@mraspaud I'm working on refactoring this and I'd like to remove the ability to use Additional question: Should the globals dictionary have attribute keys with self["/attrs"]["some_key"]
# versus
self["/attrs"]["/attr/some_key"] |
Thank you. There is no problem with that. I prefer
, but I have no strong preference or reason for it. |
Sounds good. I agree that |
Ok this is ready for re-review. Global attributes are available as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, it's nice with the simplification of the interface
In the
NetCDF4FileHandler
, it can't get all global_attributes in NetCDF with a single command.I think
NetCDF4FileHandler
should have a method to get all global_attributes at once without the attribute’s name.In this PR, we can access all global_attributes with
wrapper['/attr']
orwrapper['/attrs']