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.
@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.
Oops! Swap did occur 😒 Will shift it back!
lib/iris/fileformats/rules.py
Outdated
| @@ -1034,6 +1030,15 @@ def loadcubes_user_callback_wrapper(cube, field, filename): | |||
| cube = iris.io.run_callback(user_callback, cube, field, filename) | |||
There was a problem hiding this comment.
@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