Skip to content
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

Catch only ParameterNotUsed warnings in _catch_warnings #2753

Merged
merged 8 commits into from
Sep 9, 2021

Conversation

eccabay
Copy link
Contributor

@eccabay eccabay commented Sep 8, 2021

Closes #2652

@codecov
Copy link

codecov bot commented Sep 8, 2021

Codecov Report

Merging #2753 (62068c4) into main (2452d3f) will increase coverage by 0.1%.
The diff coverage is 100.0%.

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #2753     +/-   ##
=======================================
+ Coverage   99.9%   99.9%   +0.1%     
=======================================
  Files        300     300             
  Lines      27705   27716     +11     
=======================================
+ Hits       27656   27667     +11     
  Misses        49      49             
Impacted Files Coverage Δ
evalml/automl/automl_search.py 99.9% <100.0%> (+0.1%) ⬆️
evalml/tests/automl_tests/test_automl.py 99.7% <100.0%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2452d3f...62068c4. Read the comment docs.

@eccabay eccabay marked this pull request as ready for review September 8, 2021 19:49
Copy link
Contributor

@angela97lin angela97lin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it, LGTM! 😁

def test_pipeline_parameter_warnings_only_parameternotused(
mock_data_check, X_y_regression
):
mock_data_check.side_effect = UserWarning("Big bad warning")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it 😂

@eccabay eccabay merged commit 9143275 into main Sep 9, 2021
@eccabay eccabay deleted the 2652_catch_warnings_bug branch September 9, 2021 19:58
else:
final_message = final_message.intersection(msg.message.components)
warnings.warn(ParameterNotUsedWarning(final_message))
if isinstance(msg.message, ParameterNotUsedWarning):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a bug here? What if the warning list is [RandomWarning(...), ParameterNotUsedWarning(...)].
Then idx will be 1 when the isinstance check is true so we'll do the intersection of an empty set and the ParameterNotUsedWarning, so we'll wipe out the warning we want to log?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh shoot, I just merged this but you're totally right 🤦‍♀️

It should be a pretty simple fix to replace the idx check with checking if the set is empty or not instead - I'll put up a PR for that shortly!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there is a bug here, but it's not that! The check of if len(warning_list) == len(self.allowed_pipelines) and len(warning_list) > 0: would prevent the warning list of [RandomWarning(...), ParameterNotUsedWarning(...)] from ever reaching that point in the code, since in that case len(warning_list != len(self.allowed_pipelines).

So in this case we would indeed fail to log the ParameterNotUsedWarning, but not for the reason highlighted.

Also, this highlights another issue where we currently catch and then do not raise all non-ParameterNotUsedWarning warnings during make_pipeline. Some sleuthing found that PR #2564 added the warning catches where they were not before, so this behavior was unwanted but introduced then. I'm going to file an issue and put up a PR for raising all warnings here again, since the size of this change just grew.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants