Skip to content

Clear internal caches when re-creating from same SMIRNOFF objects#1456

Merged
mattwthompson merged 12 commits intomainfrom
clear-internal-caches
Apr 29, 2026
Merged

Clear internal caches when re-creating from same SMIRNOFF objects#1456
mattwthompson merged 12 commits intomainfrom
clear-internal-caches

Conversation

@mattwthompson
Copy link
Copy Markdown
Member

@mattwthompson mattwthompson commented Mar 2, 2026

Description

Another possible fix for #1453, including the test @j-wags added

A problem with the _clear_cache function introduced in #1435 is that it went through all objects visible to the garbage collector (!) and only interacted with objects that are themselves internal to the openff.interchange namespace. This is casting a net that is awfully wide and unnecessary since we already know what caches we want to clear. Since the crux of the bad behavior can be traced to two internal functions (see here for a good example) we don't need to iterate so widely.

Put another way: the problematic cached functions1 are only two in number and inside of Interchange. We can just clear those specific function caches directly when we need to.

Checklist

  • Add tests
  • Lint
  • Update docstrings

Footnotes

  1. and they do nothing but look up parameters inside of ParameterHandlers, see https://github.com/openforcefield/openff-toolkit/issues/2065

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.06%. Comparing base (14cd931) to head (d981804).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1456      +/-   ##
==========================================
- Coverage   94.07%   94.06%   -0.02%     
==========================================
  Files          73       73              
  Lines        6045     6034      -11     
==========================================
- Hits         5687     5676      -11     
  Misses        358      358              

☔ 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.

@mattwthompson mattwthompson marked this pull request as draft April 7, 2026 16:54
@mattwthompson mattwthompson marked this pull request as ready for review April 27, 2026 20:36
Comment thread openff/interchange/smirnoff/_create.py Outdated
Co-authored-by: Jeff Wagner <jwagnerjpl@gmail.com>
@mattwthompson mattwthompson merged commit b01c487 into main Apr 29, 2026
16 checks passed
@mattwthompson mattwthompson added this to the 0.5.3 milestone Apr 29, 2026
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