Skip to content

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

Open
mattwthompson wants to merge 4 commits intomainfrom
clear-internal-caches
Open

Clear internal caches when re-creating from same SMIRNOFF objects#1456
mattwthompson wants to merge 4 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 93.96%. Comparing base (d982ea4) to head (1731b6b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1456      +/-   ##
==========================================
- Coverage   93.97%   93.96%   -0.01%     
==========================================
  Files          73       73              
  Lines        6340     6334       -6     
==========================================
- Hits         5958     5952       -6     
  Misses        382      382              

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

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