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

Make sure top-level model is not garbage collected in UnitTestHarness #1317

Merged
merged 9 commits into from
Feb 29, 2024

Conversation

bknueven
Copy link
Contributor

@bknueven bknueven commented Feb 28, 2024

Fixes/Resolves: N/A

Fixes failures on #1301.

Summary/Motivation:

The UnitTestHarness was implemented in such a fashion that the top-level Pyomo model could be garbage collected while it was running, leading to unpredictable behavior. This unpredictable behavior can be made deterministic by manually invoking Python's garbage collector (409e529).

This PR would make a few changes to the UnitTestHarness API to ensure the top-level Pyomo model is not garbage collected during tests. It also updates the UnitTestHarness to use the IDAES initialization_tester function, as this was now an easy fix.

Changes proposed in this PR:

  • Demonstrate problem (409e529)
  • Return top-level model from configure (9f31b1d)
  • Use IDAES initialization_tester (52e18eb)
  • Add top-level model to frame to ensure its not GC'ed (f93d5c1)
  • Update documentation (761cd02)
  • Cleanup from 409e529 (f9eff1b)
  • Make UnitTestHarness a proper abstract base class (ba7d92f)

Legal Acknowledgement

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

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  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.

@bknueven bknueven marked this pull request as ready for review February 28, 2024 19:37
@bknueven bknueven mentioned this pull request Feb 28, 2024
Copy link

codecov bot commented Feb 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.39%. Comparing base (d035b7e) to head (f05bd50).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1317   +/-   ##
=======================================
  Coverage   94.39%   94.39%           
=======================================
  Files         371      371           
  Lines       37922    37922           
=======================================
  Hits        35796    35796           
  Misses       2126     2126           

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

Copy link
Contributor

@MarcusHolly MarcusHolly left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for handling this

@ksbeattie ksbeattie added the Priority:High High Priority Issue or PR label Feb 29, 2024
@ksbeattie ksbeattie merged commit 1ee5494 into watertap-org:main Feb 29, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:High High Priority Issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants