iris icon indicating copy to clipboard operation
iris copied to clipboard

Prevent warning repeats

Open stephenworsley opened this issue 2 years ago • 3 comments

🚀 Pull Request

Attempts to address #5464, the result of investigations done for #5499.

This approach attempts to align the behaviour of warnings more closely with what ought to be the default behaviour of warnings. This currently comes at the expense of "hard coding" some of this behaviour to match what you would get when calling warnings.simplefilter("default"). When setting warnings.simplefilter("always") the expected behaviour would be for all warnings to be raised, however some will be caught, as per the behaviour of warnings.simplefilter("default"). Similarly, this does not go as far as to guarantee that warnings.simplefilter("once") will behave as expected, though it should not introduce any duplications that weren't already present.

The above problems could potentially be solved with some additional logic if I could figure out a way to determine which of these behaviours warnings expected at any given point in the code. Otherwise, it may be an acceptable payoff to hardcode this behaviour if it would reduce unwanted warnings in most cases.

stephenworsley avatar Sep 20 '23 13:09 stephenworsley

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (a47fd34) 89.71% compared to head (83859f7) 89.37%. Report is 5 commits behind head on main.

:exclamation: Current head 83859f7 differs from pull request most recent head 7e8871e. Consider uploading reports for the commit 7e8871e to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5506      +/-   ##
==========================================
- Coverage   89.71%   89.37%   -0.34%     
==========================================
  Files          90       89       -1     
  Lines       22815    22456     -359     
  Branches     5438     5388      -50     
==========================================
- Hits        20468    20071     -397     
- Misses       1617     1639      +22     
- Partials      730      746      +16     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Sep 20 '23 14:09 codecov[bot]

Before

image

After

image

(forgive the difference in test numbers - different PRs)

trexfeathers avatar Sep 21 '23 08:09 trexfeathers

Thanks @ESadek-MO and @stephenworsley for exploring alternative solutions (#5536). I'm still unhappy that this PR effectively disables some of the actions in the Python warnings filter, but we've effectively been backed into that corner by forces outside our control.

Thankfully, we now have documentation about Iris warnings: filtering_warnings.rst. I would be worth:

  1. Adding a heading/admonitions to filtering_warnings.rst to clearly document Iris' deviation from standard Python behaviour.
  2. Reviewing the existing text of filtering_warnings.rst to check it is not misleading in light of the changes in this PR.

trexfeathers avatar Jan 12 '24 12:01 trexfeathers