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

Warn when infeasibility tools will not log output #2666

Merged
merged 2 commits into from
Dec 15, 2022

Conversation

jsiirola
Copy link
Member

Fixes # .

Summary/Motivation:

One of our developers was recently burned by using log_infeasible_constraints() and assuming that because they didn't see any output that the model was feasible. In fact the model was infeasible; but, because the default Pyomo logging level is WARNING, the log messages were suppressed.

This PR is a quick fix to emit a warning when the infeasibility tools are called with a logger that will not output INFO level messages.

Changes proposed in this PR:

  • Log a warning when the logger passed to pyomo.util.infeasible.log_*() will not emit INFO level messages

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@codecov
Copy link

codecov bot commented Dec 14, 2022

Codecov Report

Base: 87.05% // Head: 87.05% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (6129401) compared to base (d048745).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2666   +/-   ##
=======================================
  Coverage   87.05%   87.05%           
=======================================
  Files         757      757           
  Lines       84443    84449    +6     
=======================================
+ Hits        73512    73518    +6     
  Misses      10931    10931           
Flag Coverage Δ
linux 84.49% <100.00%> (+<0.01%) ⬆️
osx 74.96% <100.00%> (+<0.01%) ⬆️
other 84.68% <100.00%> (+<0.01%) ⬆️
win 81.83% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pyomo/util/infeasible.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

logger.warning(
'log_infeasible_constraints() called with a logger whose '
'effective level is higher than logging.INFO: no output '
'will be logged reguardless of constraint feasibility'
Copy link
Member

Choose a reason for hiding this comment

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

Repeated Typo: regardless

Copy link
Member

Choose a reason for hiding this comment

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

Should this warning include a note on how to change the logging level?
"This warning can be avoided by changing the Pyomo logging level: <CODE TO CHANGE LOGGING LEVEL>"

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so. There are too many ways to change the logging level (adding handlers, calling a standard setup, setting the logging level) to put something specific here. If we start to see a bunch of questions about it, then we can add a reference to the online docs (in the Common Warnings/Errors list) -- where we can have a longer and more detailed discussion.

pyomo/util/tests/test_infeasible.py Outdated Show resolved Hide resolved
@jsiirola jsiirola merged commit 3119236 into Pyomo:main Dec 15, 2022
@jsiirola jsiirola deleted the infeasibility-logger-warning branch December 15, 2022 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants