-
Notifications
You must be signed in to change notification settings - Fork 283
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
Diagnose source of duplicated Iris warnings #5463
Comments
Took the warning summary from a recent Pytest run to take a look at this. 15717 warnings in total, 882 lines in the file. A few highlights
|
After conducting some experiments, I'm now of the conclusion that I used the following simple script as the basis of the investigation: import iris
dname = "/home/h05/itwl/projects/git/iris-test-data/test_data/NetCDF/mercator"
fnames = ["false_east_north_merc.nc", "non_unit_scale_factor_merc.nc", "toa_brightness_temperature.nc"]
for fname in fnames:
print(fname)
_ = iris.load_cube(f"{dname}/{fname}") (Note that, this script was call with Which should generate the following single warning to the console, but instead it occurs 3 times, once for each netCDF file loaded:
This warning is generated as part of the The approach taken was to reduce the functionality within the Initial "hunches" of culprits revolved around:
i.e., this is all seeded by the statement in the warnings documentation that the Note that, the It was observed that the ID object instance of the Essentially, I was able to eventually able to incrementally turn-off all of the In essence, we see duplicate warnings and yet not call any of the Stripping the problem right back to the bare bones, the following script behaves as expected generating only 1 warning for both import warnings
for _ in range(5):
import iris
warnings.warn("oops!", category=UserWarning) However, the following pattern generates 2 warnings for both import warnings
for _ in range(5):
warnings.warn("oops", category=UserWarning)
import iris i.e., importing Note that, this behaviour is also observed when importing However, this is not the case when importing Conclusion@stephenworsley Has in parallel uncovered that this type of behaviour is a know bug with The behaviour that I've witnessed through this investigation leads me to the conclusion that My recommendation is to now investigate community work arounds, assess those, and choose the best workaround for |
A probable source for this issue appears to be a bug with the Looking through responses to this issue, it appears that there exists a relatively simple workaround using |
Also worth noting, when I stepped through loading code, this appears to be where the context manager gets called in iris code: iris/lib/iris/fileformats/_nc_load_rules/helpers.py Lines 417 to 431 in b6e39d7
|
Steps
Possible causes:
E.g. Some work happens within a
NetCDFDataProxy
, and there is one of these per chunkFinding examples
The text was updated successfully, but these errors were encountered: