-
Notifications
You must be signed in to change notification settings - Fork 300
Fix PP callback bug #2059
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
Fix PP callback bug #2059
Conversation
|
I've now added a test! Its an integration test, because I couldn't figure out how to break the functionality of |
|
Hopefully this will get the tests passing... |
|
ping @bjlittle - passing tests! |
|
@dkillick On it now ... |
| # load if no format specific desired attributes are violated | ||
| if filter_function is None or filter_function(field): | ||
| yield (field, filename) | ||
|
|
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.
@dkillick This private functions doesn't appear to have changed, apart from its position in the file.
Sorry for being a pain, but could you paste it back, as it introduces unnecessary noise, thanks.
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.
Oops! Swap did occur 😒 Will shift it back!
lib/iris/fileformats/rules.py
Outdated
| loader.legacy_custom_rules.verify(cube, field) | ||
|
|
||
| # Then also run user-provided original callback function. | ||
| cube = iris.io.run_callback(user_callback, cube, field, filename) |
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.
@dkillick For me, this is the nub of the problem, and it's not your doing.
I believe lines +1034-1035 should now simply be the following:
result = cube
if user_callback is not None:
result = user_callback(cube, field, filename)
return resultI believe the intent of the loadcubes_user_callback_wrapper was simply to
- raise the deprecation warning
- fire any registered custom user rules, then
- execute the
user_callback.
The user_callback should not be executed here by iris.io.run_callback. That's the problem.
Rather, it is the loadcubes_user_callback_wrapper that should be executed by iris.io.run_callback downstream within _load_pairs_from_fields_and_filenames, as was prior to your changes.
So make the above change, then back-out your patch to _load_pairs_from_fields_and_filenames and replace it with
cube = iris.io.run_callback(user_callback, cube, field, filename)
if cube is None:
continue|
@dkillick Great, thanks! |
Fixes a bug (see #2052) where the
IgnoreCubeExceptionwas not being respected in loading the loading of PP files with a user callback.No tests yet, primarily because there are no tests for this behaviour at all (which is probably why this slipped through in the first place).
Closes #2052