Skip to content

Conversation

@hannahbaumann
Copy link
Contributor

@hannahbaumann hannahbaumann commented Jan 19, 2026

Fixes #43 and #67

This PR:

  • Closes netcdfs both in the code and in the test
  • Adds pooch caching back in
  • Updates the test; the new simulation_skipped dataset is from CDK2, which has two chains. Since the multichain fix is not in yet, this test currently has large RMSDs
  • Removes flaky argument in tests
  • Uses the skipped test dataset in more tests for not having to use the bigger one everywhere.

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.05%. Comparing base (5260e3b) to head (2a1d130).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/openfe_analysis/rmsd.py 97.14% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #70      +/-   ##
==========================================
- Coverage   88.16%   87.05%   -1.11%     
==========================================
  Files           7        7              
  Lines         338      340       +2     
==========================================
- Hits          298      296       -2     
- Misses         40       44       +4     

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

assert ts.time == times[inx]
assert np.all(u.atoms.positions > 0)
# Positions are not all zero since PBC is not removed
assert np.any(u.atoms.positions != 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@IAlibay : This is what I mentioned yesterday. The positions in this nc file are not always >0.

Copy link
Member

Choose a reason for hiding this comment

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

Ok thanks, that's interesting..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I add this u.trajectory.add_transformations(wrap(u.atoms)) it passes the >0 check.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I think if wrap behaves well then it's fine. We might need to check this later when we do viz thing, but either way it's not like a regression is being added in this code, so we should be good.

@hannahbaumann hannahbaumann changed the title [WIP ] Closing netcdfs properly Fixing flaky tests Jan 28, 2026
This was referenced Jan 28, 2026
@hannahbaumann hannahbaumann linked an issue Jan 28, 2026 that may be closed by this pull request
@hannahbaumann hannahbaumann linked an issue Jan 28, 2026 that may be closed by this pull request
@hannahbaumann
Copy link
Contributor Author

pre-commit.ci autofix

Comment on lines +73 to +74
base_url=ZENODO_DOI,
registry=ZENODO_FILES,
Copy link
Contributor

Choose a reason for hiding this comment

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

glad you're doing this! it's what I'm moving us toward on the openfe side.

@atravitz
Copy link
Contributor

@hannahbaumann you'll want to build pooch from main (like we are here in openfe) if you're seeing issues with fetching data.

Comment on lines +22 to +23
yield u
u.trajectory.close()
Copy link
Contributor

Choose a reason for hiding this comment

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

should we be doing the same here in openfe?

Copy link
Member

Choose a reason for hiding this comment

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

No, xtc files, and trajectories in MDAnalysis overall, do not need this - close should get called on garbage collection and xtc files don't have concurrency issues.

Copy link
Member

Choose a reason for hiding this comment

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

See above - close gets called by __del__ for trajectories, it shouldn't be needed unless there's weird things happening.

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Couple of things, still looking into that positions thing.

POOCH_CACHE = pooch.os_cache("openfe_analysis")
ZENODO_DOI = "doi:10.5281/zenodo.18378051"

ZENODO_FILES = {
Copy link
Member

Choose a reason for hiding this comment

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

We should probably have an "HAS_INTERNET" check on most of our tests.
Maybe todo in a separate issue?



def test_universe_creation(simulation_nc, hybrid_system_pdb):
with pytest.warns(UserWarning, match="This is an older NetCDF file that"):
Copy link
Member

Choose a reason for hiding this comment

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

Do we still have a test somewhere to warn for the old netcdf file types?

If not, can we mock one?

assert_allclose(u.dimensions, [82.191055, 82.191055, 82.191055, 90.0, 90.0, 90.0])
assert_allclose(u.dimensions, [78.141495, 78.141495, 78.141495, 60.0, 60.0, 90.0])

u.trajectory.close()
Copy link
Member

Choose a reason for hiding this comment

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

Are these actually necessary now? __del__ should call self.close (it's a reader thing), so they should get garbage collected when they go out of scope, if they don't then we might still be encountering an issue with closing the files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not seeing failures without this, I had put it since I wasn't sure if things could be unstable when lots of test run in parallel, but we could remove it for now and if we see problems later again, investigate further?

Copy link
Member

Choose a reason for hiding this comment

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

Since it's only in tests, I would vote for removing and seeing how we fare - it's a good canary.

Comment on lines +22 to +23
yield u
u.trajectory.close()
Copy link
Member

Choose a reason for hiding this comment

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

See above - close gets called by __del__ for trajectories, it shouldn't be needed unless there's weird things happening.

key: pooch-${{ matrix.os }}-v2

- name: "Download Zenodo data"
shell: python
Copy link
Member

Choose a reason for hiding this comment

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

Ah sorry @hannahbaumann - I was wrong, it looks like this might use some other python (not the one from micromamba)!

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.

improve file clean up Tests are flaky - unclosed NetCDF datasets?

4 participants