-
Notifications
You must be signed in to change notification settings - Fork 296
Generalise support for netcdf load+save of "special" attributes #6566
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6566 +/- ##
==========================================
- Coverage 89.94% 89.93% -0.02%
==========================================
Files 90 91 +1
Lines 24302 24385 +83
Branches 4546 4554 +8
==========================================
+ Hits 21859 21930 +71
- Misses 1674 1686 +12
Partials 769 769 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
⏱️ Performance Benchmark Report: 71c7bc4Performance shifts
Full benchmark results
Generated by GHA run |
ad34c83
to
dc0c441
Compare
…d/save code, not handlers.
…hout split-attrs.
afa11e5
to
9d90853
Compare
Review Notes : changes to considerThe code changes here provoked review of some older behaviour decisions. Here's a summary, which may not be entirely complete: overall
STASH
ukmo__process_flags
GRIB_PARAM
|
Uncertainty remaining
|
78d96e8
to
7226b36
Compare
Update:
I'm now thinking that, without any further changes here, I can just import the tests which are here skipped due to iris-grib not being installed, and run them in the iris-grib repo instead. Does that sound like a good plan ? |
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.
@pp-mo Looks good.
You've had to grapple with some serious sketchy historical code that's evolved over time. Unifying it should make it more understandable and maintainable.
I can't see any obvious behaviour changes that will upset users, so I'm happy to roll with what you've suggested and we can see whether there are any user edge cases that may require a patch or rebuffing.
Thanks for adding the additional test coverage 🤩💯
Only a few minors to service 👍
""" | ||
|
||
from abc import ABCMeta, abstractmethod | ||
from typing import Any, Dict, List, Tuple |
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.
@pp-mo As from >=py39
(PEP585) you now no longer need to import Dict
, List
or Tuple
. It's safe to use the built-in equivalents i.e., dict
, list
and tuple
👍
NetcdfIdentifyingNames: List[str] = [] | ||
|
||
@abstractmethod | ||
def encode_object(self, content) -> Tuple[str, str]: |
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.
@pp-mo Do you we have a type annotation for content
?
There are other various missing annotations below ...
Not too sure how strict you want to be on type annotations just yet in iris
... the coverage and adoption is patchy at best.
I'd err on the side of either typing everything new or not at all. Your call.
pass | ||
|
||
@abstractmethod | ||
def decode_attribute(self, attr_name: str, attr_value) -> Any: |
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.
@pp-mo attr_name
is never used in any the subclass methods, so why is it part of the abstract method?
Is there something I've misunderstood?
) | ||
warnings.warn(msg, category=_WarnComboLoadIgnoring) | ||
|
||
if len(matches) > 0: |
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.
if len(matches) > 0: | |
if len(matches) == 1: |
var = engine.cf_var | ||
for handler in ATTRIBUTE_HANDLERS.values(): | ||
# Each handler can have several match names, but ideally only 0 or 1 appears ! | ||
iris_name = handler.IrisIdentifyingName |
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.
@pp-mo Super minor, but you could offer a read-only property, for example, on the handler that allows the user of the instance to get the iris or netcdf name without having to know the name of the class property that they're stored in e.g., handler.iris_name
and handler.netcdf_name
Happy for you not to do this, just an observation/suggestion.
Closes SciTools/iris-grib#596 and SciTools/iris-grib#674
Ties together the handling of STASH, GRIB_PARAM and "ukmo__process_flags" attributes,
which all require special handling on netcdf load+save.
By design, should preserve existing behaviour.
But I have tried to generalise the handling,
( and also rationalise behaviour a wee bit, at least for "ukmo__process_flags" -- though that one is quite obscure ).
TODO:
@staticmethod
+ useself
more(but first, just let's see if it breaks anything I haven't already tried)