Skip to content

Conversation

@dallan-keylogic
Copy link
Contributor

Summary/Motivation:

When trying to run tests in WaterTap that depended on the IDAES PropertyTestHarness, I encountered a strange error in Pytest:

E                   pytest.PytestUnraisableExceptionWarning: Exception ignored in: <_io.FileIO name='C:\\Users\\[REDACTED]\\Repos\\idaes-pse\\.git\\refs/heads/diagnostics_toolbox_scaling' mode='rb' closefd=True>
E                   Enable tracemalloc to get traceback where the object was allocated.
E                   See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

..\..\..\..\..\miniforge3\envs\watertap-dev\Lib\site-packages\_pytest\unraisableexception.py:67: PytestUnraisableExceptionWarnin

diagnostics_toolbox_scaling was my local IDAES branch.

After doing some troubleshooting, I was able to trace this problem to ver.py:

        try:
>           ref = open(ref_file).read().strip()
                  ^^^^^^^^^^^^^^^^^^^^^
E           ResourceWarning: unclosed file <_io.TextIOWrapper name='C:\\Users\\[REDACTED]\\Repos\\idaes-pse\\.git\\refs/heads/diagnostics_toolbox_scaling' mode='r' encoding='cp1252'>

..\..\..\..\idaes-pse\idaes\ver.py:167: ResourceWarning

It appears that we had a minor memory leak from opening files without closing them. I've made some minor modifications to close the files after we're done with them.

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.

@dallan-keylogic dallan-keylogic marked this pull request as ready for review November 5, 2025 22:14
@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 16.66667% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.44%. Comparing base (ee67e29) to head (c647f10).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
idaes/ver.py 16.66% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1698      +/-   ##
==========================================
- Coverage   77.46%   77.44%   -0.02%     
==========================================
  Files         395      395              
  Lines       64760    64763       +3     
  Branches    10897    10897              
==========================================
- Hits        50168    50158      -10     
- Misses      12084    12094      +10     
- Partials     2508     2511       +3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dallan-keylogic dallan-keylogic added the CI:run-integration triggers_workflow: Integration label Nov 6, 2025
@idaes-build idaes-build removed the CI:run-integration triggers_workflow: Integration label Nov 6, 2025
@ksbeattie ksbeattie added the Priority:High High Priority Issue or PR label Nov 6, 2025
Copy link
Member

@ksbeattie ksbeattie left a comment

Choose a reason for hiding this comment

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

LGTM

@sufikaur
Copy link
Contributor

Another potential solution could be into using a context manager. However, since this file should go away soon, this solution is good.

The way to remove this file is setuptools_scm (see pyproject.toml PR)

@ksbeattie ksbeattie merged commit 36e6eb8 into IDAES:main Nov 13, 2025
59 of 61 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