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

Update report_timing() to support context manager API #3039

Merged
merged 6 commits into from
Nov 20, 2023

Conversation

jsiirola
Copy link
Member

Fixes # .

Summary/Motivation:

This updates the old report_timing() function so that it can be used as a context manager. When used as a context manager, it will undo the changes that it made to the timing loggers upon exit from the context. Among other things, this prevents side effects from enabling report_timing in model.create_instance() and makes it easier to exercise the timing statements in the transformations and writers.

This also adds a test that exercises the timing reporting for the NLv2 (which was the original motivation)

Changes proposed in this PR:

  • Convert report_timing() to support use as a context manager
  • Use report_timing() context manager in Model.create_instance()
  • Add test exercising timing in NLv2 writer

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.

Copy link

codecov bot commented Nov 15, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (15a7bff) 87.96% compared to head (b12ce95) 87.97%.

Files Patch % Lines
pyomo/core/base/PyomoModel.py 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3039      +/-   ##
==========================================
+ Coverage   87.96%   87.97%   +0.01%     
==========================================
  Files         770      770              
  Lines       90162    90178      +16     
==========================================
+ Hits        79310    79336      +26     
+ Misses      10852    10842      -10     
Flag Coverage Δ
linux 85.30% <98.11%> (+0.01%) ⬆️
osx 75.12% <98.11%> (+0.01%) ⬆️
other 85.48% <98.11%> (+0.01%) ⬆️
win 82.55% <98.11%> (+0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mrmundt mrmundt merged commit 061571b into Pyomo:main Nov 20, 2023
30 checks passed
@jsiirola jsiirola deleted the nlv2-test-timing branch November 20, 2023 21:17
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.

3 participants