From 4dc86178c045e3b5f1b528c6fb133a20f07195c5 Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 13:44:13 +0100 Subject: [PATCH 01/19] fully disable flaky test --- src/openfe_analysis/tests/test_reader.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/openfe_analysis/tests/test_reader.py b/src/openfe_analysis/tests/test_reader.py index 6cef163..6a520bb 100644 --- a/src/openfe_analysis/tests/test_reader.py +++ b/src/openfe_analysis/tests/test_reader.py @@ -152,13 +152,13 @@ def test_fereader_negative_replica(simulation_nc, hybrid_system_pdb): assert u.trajectory._replica_id == 9 -@pytest.mark.parametrize("rep_id, state_id", [[None, None], [1, 1]]) -@pytest.mark.flaky(reruns=3) -def test_fereader_replica_state_id_error(simulation_nc, hybrid_system_pdb, rep_id, state_id): - with pytest.raises(ValueError, match="Specify one and only one"): - _ = mda.Universe( - hybrid_system_pdb, simulation_nc, format=FEReader, state_id=state_id, replica_id=rep_id - ) +#@pytest.mark.parametrize("rep_id, state_id", [[None, None], [1, 1]]) +#@pytest.mark.flaky(reruns=3) +#def test_fereader_replica_state_id_error(simulation_nc, hybrid_system_pdb, rep_id, state_id): +# with pytest.raises(ValueError, match="Specify one and only one"): +# _ = mda.Universe( +# hybrid_system_pdb, simulation_nc, format=FEReader, state_id=state_id, replica_id=rep_id +# ) def test_simulation_skipped_nc(simulation_skipped_nc, hybrid_system_skipped_pdb): From d8b15d23d72fc8e7d2c2e5c362f58ac7753f9186 Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 13:48:47 +0100 Subject: [PATCH 02/19] make everything not session scoped --- src/openfe_analysis/tests/conftest.py | 10 +++++----- src/openfe_analysis/tests/test_reader.py | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/openfe_analysis/tests/conftest.py b/src/openfe_analysis/tests/conftest.py index f759b52..36a46a6 100644 --- a/src/openfe_analysis/tests/conftest.py +++ b/src/openfe_analysis/tests/conftest.py @@ -26,27 +26,27 @@ ) -@pytest.fixture(scope="session") +@pytest.fixture() def simulation_nc(): return RFE_OUTPUT.fetch("simulation.nc") -@pytest.fixture(scope="session") +@pytest.fixture() def simulation_skipped_nc(): return RFE_OUTPUT_skipped_frames.fetch("simulation.nc") -@pytest.fixture(scope="session") +@pytest.fixture() def hybrid_system_pdb(): return RFE_OUTPUT.fetch("hybrid_system.pdb") -@pytest.fixture(scope="session") +@pytest.fixture() def hybrid_system_skipped_pdb(): return RFE_OUTPUT_skipped_frames.fetch("hybrid_system.pdb") -@pytest.fixture(scope="session") +@pytest.fixture() def mcmc_serialized(): return ( "_serialized__class_name: LangevinDynamicsMove\n" diff --git a/src/openfe_analysis/tests/test_reader.py b/src/openfe_analysis/tests/test_reader.py index 6a520bb..6cef163 100644 --- a/src/openfe_analysis/tests/test_reader.py +++ b/src/openfe_analysis/tests/test_reader.py @@ -152,13 +152,13 @@ def test_fereader_negative_replica(simulation_nc, hybrid_system_pdb): assert u.trajectory._replica_id == 9 -#@pytest.mark.parametrize("rep_id, state_id", [[None, None], [1, 1]]) -#@pytest.mark.flaky(reruns=3) -#def test_fereader_replica_state_id_error(simulation_nc, hybrid_system_pdb, rep_id, state_id): -# with pytest.raises(ValueError, match="Specify one and only one"): -# _ = mda.Universe( -# hybrid_system_pdb, simulation_nc, format=FEReader, state_id=state_id, replica_id=rep_id -# ) +@pytest.mark.parametrize("rep_id, state_id", [[None, None], [1, 1]]) +@pytest.mark.flaky(reruns=3) +def test_fereader_replica_state_id_error(simulation_nc, hybrid_system_pdb, rep_id, state_id): + with pytest.raises(ValueError, match="Specify one and only one"): + _ = mda.Universe( + hybrid_system_pdb, simulation_nc, format=FEReader, state_id=state_id, replica_id=rep_id + ) def test_simulation_skipped_nc(simulation_skipped_nc, hybrid_system_skipped_pdb): From 19fd5acd072c3d67c4aba803479905accae7a3ae Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 13:51:19 +0100 Subject: [PATCH 03/19] remove that one too --- src/openfe_analysis/tests/utils/test_multistate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/openfe_analysis/tests/utils/test_multistate.py b/src/openfe_analysis/tests/utils/test_multistate.py index deb3281..3751743 100644 --- a/src/openfe_analysis/tests/utils/test_multistate.py +++ b/src/openfe_analysis/tests/utils/test_multistate.py @@ -13,7 +13,6 @@ ) -@pytest.fixture(scope="module") def dataset(simulation_nc): return nc.Dataset(simulation_nc) From 1470d76feb864622a18b60798c549754b125edb3 Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 14:07:07 +0100 Subject: [PATCH 04/19] add some safeties --- src/openfe_analysis/tests/conftest.py | 27 ++++++++++++++----- src/openfe_analysis/tests/test_reader.py | 1 + .../tests/utils/test_multistate.py | 3 +++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/openfe_analysis/tests/conftest.py b/src/openfe_analysis/tests/conftest.py index 36a46a6..24bace8 100644 --- a/src/openfe_analysis/tests/conftest.py +++ b/src/openfe_analysis/tests/conftest.py @@ -2,9 +2,20 @@ import pooch import pytest +import urllib.request + +try: + urllib.request.urlopen('https://www.google.com') +except: # -no-cov- + HAS_INTERNET = False +else: + HAS_INTERNET = True + + +POOCH_CACHE = pooch.os_cache("openfe_analysis") RFE_OUTPUT = pooch.create( - path=pooch.os_cache("openfe_analysis"), + path=POOCH_CACHE, base_url="doi:10.6084/m9.figshare.24101655", registry={ "checkpoint.nc": "5af398cb14340fddf7492114998b244424b6c3f4514b2e07e4bd411484c08464", @@ -13,40 +24,42 @@ "simulation.nc": "92361a0864d4359a75399470135f56642b72c605069a4c33dbc4be6f91f28b31", "simulation_real_time_analysis.yaml": "65706002f371fafba96037f29b054fd7e050e442915205df88567f48f5e5e1cf", # noqa: E501 }, + retry_if_failed=5, ) RFE_OUTPUT_skipped_frames = pooch.create( - path=pooch.os_cache("openfe_analysis_skipped"), + path=POOCH_CACHE, base_url="doi:10.6084/m9.figshare.28263203", registry={ "hybrid_system.pdb": "77c7914b78724e568f38d5a308d36923f5837c03a1d094e26320b20aeec65fee", "simulation.nc": "6749e2c895f16b7e4eba196261c34756a0a062741d36cc74925676b91a36d0cd", }, + retry_if_failed=5, ) -@pytest.fixture() +@pytest.fixture(scope='session') def simulation_nc(): return RFE_OUTPUT.fetch("simulation.nc") -@pytest.fixture() +@pytest.fixture(scope='session') def simulation_skipped_nc(): return RFE_OUTPUT_skipped_frames.fetch("simulation.nc") -@pytest.fixture() +@pytest.fixture(scope='session') def hybrid_system_pdb(): return RFE_OUTPUT.fetch("hybrid_system.pdb") -@pytest.fixture() +@pytest.fixture(scope='session') def hybrid_system_skipped_pdb(): return RFE_OUTPUT_skipped_frames.fetch("hybrid_system.pdb") -@pytest.fixture() +@pytest.fixture(scope='session') def mcmc_serialized(): return ( "_serialized__class_name: LangevinDynamicsMove\n" diff --git a/src/openfe_analysis/tests/test_reader.py b/src/openfe_analysis/tests/test_reader.py index 6cef163..02918c6 100644 --- a/src/openfe_analysis/tests/test_reader.py +++ b/src/openfe_analysis/tests/test_reader.py @@ -116,6 +116,7 @@ def test_universe_from_nc_file(simulation_nc, hybrid_system_pdb): assert len(u.atoms) == 4782 assert len(u.trajectory) == 501 assert u.trajectory.dt == pytest.approx(1.0) + ds.close() def test_universe_creation_noconversion(simulation_nc, hybrid_system_pdb): diff --git a/src/openfe_analysis/tests/utils/test_multistate.py b/src/openfe_analysis/tests/utils/test_multistate.py index 3751743..0490436 100644 --- a/src/openfe_analysis/tests/utils/test_multistate.py +++ b/src/openfe_analysis/tests/utils/test_multistate.py @@ -13,6 +13,7 @@ ) +@pytest.fixture(scope='module') def dataset(simulation_nc): return nc.Dataset(simulation_nc) @@ -84,3 +85,5 @@ def test_simulation_skipped_nc_no_positions_box_vectors_frame1( assert _get_unitcell(dataset, 1, 1) is None assert dataset.variables["positions"][1][0].mask.all() + + dataset.close() From b196ce77013363687f91e38cb645d1c3b3f23fb3 Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 14:13:56 +0100 Subject: [PATCH 05/19] try forcing the close in gather_rms_data --- src/openfe_analysis/rmsd.py | 2 ++ src/openfe_analysis/tests/test_reader.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/openfe_analysis/rmsd.py b/src/openfe_analysis/rmsd.py index 7d2af13..b7243d6 100644 --- a/src/openfe_analysis/rmsd.py +++ b/src/openfe_analysis/rmsd.py @@ -179,6 +179,8 @@ def gather_rms_data( output["time(ps)"] = list(np.arange(len(u.trajectory))[::skip] * u.trajectory.dt) + ds.close() + return output diff --git a/src/openfe_analysis/tests/test_reader.py b/src/openfe_analysis/tests/test_reader.py index 02918c6..473e577 100644 --- a/src/openfe_analysis/tests/test_reader.py +++ b/src/openfe_analysis/tests/test_reader.py @@ -179,3 +179,5 @@ def test_simulation_skipped_nc(simulation_skipped_nc, hybrid_system_skipped_pdb) assert np.all(u.atoms.positions > 0) with pytest.raises(mda.exceptions.NoDataError, match="This Timestep has no velocities"): u.atoms.velocities + + u.trajectory.close() From 4a2d3b67ebeeeb81ebc70f95d41d4400b353a6d3 Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 14:19:52 +0100 Subject: [PATCH 06/19] disable all the flaky calls --- src/openfe_analysis/tests/test_reader.py | 2 +- src/openfe_analysis/tests/test_rmsd.py | 4 ++-- src/openfe_analysis/tests/test_transformations.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/openfe_analysis/tests/test_reader.py b/src/openfe_analysis/tests/test_reader.py index 473e577..52fabf6 100644 --- a/src/openfe_analysis/tests/test_reader.py +++ b/src/openfe_analysis/tests/test_reader.py @@ -154,7 +154,7 @@ def test_fereader_negative_replica(simulation_nc, hybrid_system_pdb): @pytest.mark.parametrize("rep_id, state_id", [[None, None], [1, 1]]) -@pytest.mark.flaky(reruns=3) +#@pytest.mark.flaky(reruns=3) def test_fereader_replica_state_id_error(simulation_nc, hybrid_system_pdb, rep_id, state_id): with pytest.raises(ValueError, match="Specify one and only one"): _ = mda.Universe( diff --git a/src/openfe_analysis/tests/test_rmsd.py b/src/openfe_analysis/tests/test_rmsd.py index a108bbe..de9585b 100644 --- a/src/openfe_analysis/tests/test_rmsd.py +++ b/src/openfe_analysis/tests/test_rmsd.py @@ -6,7 +6,7 @@ from openfe_analysis.rmsd import gather_rms_data -@pytest.mark.flaky(reruns=3) +#@pytest.mark.flaky(reruns=3) def test_gather_rms_data_regression(simulation_nc, hybrid_system_pdb): output = gather_rms_data( hybrid_system_pdb, @@ -43,7 +43,7 @@ def test_gather_rms_data_regression(simulation_nc, hybrid_system_pdb): ) -@pytest.mark.flaky(reruns=3) +#@pytest.mark.flaky(reruns=3) def test_gather_rms_data_regression_skippednc(simulation_skipped_nc, hybrid_system_skipped_pdb): output = gather_rms_data( hybrid_system_skipped_pdb, diff --git a/src/openfe_analysis/tests/test_transformations.py b/src/openfe_analysis/tests/test_transformations.py index 96d4a0f..c8b89ec 100644 --- a/src/openfe_analysis/tests/test_transformations.py +++ b/src/openfe_analysis/tests/test_transformations.py @@ -21,7 +21,7 @@ def universe(hybrid_system_pdb, simulation_nc): ) -@pytest.mark.flaky(reruns=3) +#@pytest.mark.flaky(reruns=3) def test_minimiser(universe): prot = universe.select_atoms("protein and name CA") lig = universe.select_atoms("resname UNK") @@ -34,7 +34,7 @@ def test_minimiser(universe): assert d == pytest.approx(11.10, abs=0.01) -@pytest.mark.flaky(reruns=3) +#@pytest.mark.flaky(reruns=3) def test_nojump(universe): # find frame where protein would teleport across boundary and check it prot = universe.select_atoms("protein and name CA") @@ -50,7 +50,7 @@ def test_nojump(universe): assert prot.center_of_mass() == pytest.approx(ref, abs=0.01) -@pytest.mark.flaky(reruns=3) +#@pytest.mark.flaky(reruns=3) def test_aligner(universe): # checks that rmsd is identical with/without center&super prot = universe.select_atoms("protein and name CA") From 9d88572a99bd5094e20fb2130944433fe7d10a2e Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 14:23:59 +0100 Subject: [PATCH 07/19] remove trajectory close call --- src/openfe_analysis/tests/test_reader.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/openfe_analysis/tests/test_reader.py b/src/openfe_analysis/tests/test_reader.py index 52fabf6..894a99d 100644 --- a/src/openfe_analysis/tests/test_reader.py +++ b/src/openfe_analysis/tests/test_reader.py @@ -179,5 +179,3 @@ def test_simulation_skipped_nc(simulation_skipped_nc, hybrid_system_skipped_pdb) assert np.all(u.atoms.positions > 0) with pytest.raises(mda.exceptions.NoDataError, match="This Timestep has no velocities"): u.atoms.velocities - - u.trajectory.close() From b68048bbaca7da7b92d58f03d82cc1944005b63a Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 14:29:57 +0100 Subject: [PATCH 08/19] try something --- src/openfe_analysis/reader.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/openfe_analysis/reader.py b/src/openfe_analysis/reader.py index b7677bc..b2bf23f 100644 --- a/src/openfe_analysis/reader.py +++ b/src/openfe_analysis/reader.py @@ -195,3 +195,4 @@ def _reopen(self): def close(self): if self._dataset_owner: self._dataset.close() + self._dataset = None From 4fe7a5e773b1eb3e0d29359c8a723a82f49cd46b Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 14:32:43 +0100 Subject: [PATCH 09/19] Revert something --- src/openfe_analysis/tests/conftest.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/openfe_analysis/tests/conftest.py b/src/openfe_analysis/tests/conftest.py index 24bace8..17cd43a 100644 --- a/src/openfe_analysis/tests/conftest.py +++ b/src/openfe_analysis/tests/conftest.py @@ -13,9 +13,8 @@ HAS_INTERNET = True -POOCH_CACHE = pooch.os_cache("openfe_analysis") RFE_OUTPUT = pooch.create( - path=POOCH_CACHE, + path=pooch.os_cache("openfe_analysis"), base_url="doi:10.6084/m9.figshare.24101655", registry={ "checkpoint.nc": "5af398cb14340fddf7492114998b244424b6c3f4514b2e07e4bd411484c08464", @@ -27,9 +26,8 @@ retry_if_failed=5, ) - RFE_OUTPUT_skipped_frames = pooch.create( - path=POOCH_CACHE, + path=pooch.os_cache("openfe_analysis_skipped"), base_url="doi:10.6084/m9.figshare.28263203", registry={ "hybrid_system.pdb": "77c7914b78724e568f38d5a308d36923f5837c03a1d094e26320b20aeec65fee", From 3733734820372ba61da9bb5be273d90a757a799c Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 14:38:00 +0100 Subject: [PATCH 10/19] try not to open a dataset in a single test --- src/openfe_analysis/tests/utils/test_multistate.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/openfe_analysis/tests/utils/test_multistate.py b/src/openfe_analysis/tests/utils/test_multistate.py index 0490436..ed0df42 100644 --- a/src/openfe_analysis/tests/utils/test_multistate.py +++ b/src/openfe_analysis/tests/utils/test_multistate.py @@ -18,6 +18,11 @@ def dataset(simulation_nc): return nc.Dataset(simulation_nc) +@pytest.fixture(scope='module') +def skipped_dataset(simulation_skipped_nc) + return nc.Dataset(simulation_skipped_nc) + + @pytest.mark.flaky(reruns=3) @pytest.mark.parametrize("state, frame, replica", [[0, 0, 0], [0, 1, 3], [0, -1, 7], [3, 100, 6]]) def test_state_to_replica(dataset, state, frame, replica): @@ -79,11 +84,7 @@ def test_get_unitcell(dataset): def test_simulation_skipped_nc_no_positions_box_vectors_frame1( - simulation_skipped_nc, + skipped_dataset, ): - dataset = nc.Dataset(simulation_skipped_nc) - assert _get_unitcell(dataset, 1, 1) is None assert dataset.variables["positions"][1][0].mask.all() - - dataset.close() From f4b34bbbb33bb637e9fa45f96866817a99c881ff Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 14:42:25 +0100 Subject: [PATCH 11/19] fix typo --- src/openfe_analysis/tests/utils/test_multistate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openfe_analysis/tests/utils/test_multistate.py b/src/openfe_analysis/tests/utils/test_multistate.py index ed0df42..ed9b81e 100644 --- a/src/openfe_analysis/tests/utils/test_multistate.py +++ b/src/openfe_analysis/tests/utils/test_multistate.py @@ -19,7 +19,7 @@ def dataset(simulation_nc): @pytest.fixture(scope='module') -def skipped_dataset(simulation_skipped_nc) +def skipped_dataset(simulation_skipped_nc): return nc.Dataset(simulation_skipped_nc) From bc8329459a19e595c42973b2c9afa53348f27b5d Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 14:51:21 +0100 Subject: [PATCH 12/19] try to explicitly teardown fixtures --- src/openfe_analysis/tests/test_reader.py | 7 +++++++ src/openfe_analysis/tests/test_transformations.py | 4 +++- src/openfe_analysis/tests/utils/test_multistate.py | 8 ++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/openfe_analysis/tests/test_reader.py b/src/openfe_analysis/tests/test_reader.py index 894a99d..2da246e 100644 --- a/src/openfe_analysis/tests/test_reader.py +++ b/src/openfe_analysis/tests/test_reader.py @@ -105,6 +105,8 @@ def test_universe_creation(simulation_nc, hybrid_system_pdb): ) assert_allclose(u.dimensions, [82.191055, 82.191055, 82.191055, 90.0, 90.0, 90.0]) + u.trajectory.close() + def test_universe_from_nc_file(simulation_nc, hybrid_system_pdb): ds = nc.Dataset(simulation_nc) @@ -135,6 +137,7 @@ def test_universe_creation_noconversion(simulation_nc, hybrid_system_pdb): ] ), ) + u.trajectory.close() def test_fereader_negative_state(simulation_nc, hybrid_system_pdb): @@ -143,6 +146,7 @@ def test_fereader_negative_state(simulation_nc, hybrid_system_pdb): assert u.trajectory._state_id == 10 assert u.trajectory._replica_id is None + u.trajectory.close() def test_fereader_negative_replica(simulation_nc, hybrid_system_pdb): @@ -151,6 +155,7 @@ def test_fereader_negative_replica(simulation_nc, hybrid_system_pdb): assert u.trajectory._state_id is None assert u.trajectory._replica_id == 9 + u.trajectory.close() @pytest.mark.parametrize("rep_id, state_id", [[None, None], [1, 1]]) @@ -179,3 +184,5 @@ def test_simulation_skipped_nc(simulation_skipped_nc, hybrid_system_skipped_pdb) assert np.all(u.atoms.positions > 0) with pytest.raises(mda.exceptions.NoDataError, match="This Timestep has no velocities"): u.atoms.velocities + + u.trajectory.close() diff --git a/src/openfe_analysis/tests/test_transformations.py b/src/openfe_analysis/tests/test_transformations.py index c8b89ec..3244137 100644 --- a/src/openfe_analysis/tests/test_transformations.py +++ b/src/openfe_analysis/tests/test_transformations.py @@ -13,12 +13,14 @@ @pytest.fixture def universe(hybrid_system_pdb, simulation_nc): - return mda.Universe( + u = mda.Universe( hybrid_system_pdb, simulation_nc, format="MultiStateReporter", state_id=0, ) + yield u + u.trajectory.close() #@pytest.mark.flaky(reruns=3) diff --git a/src/openfe_analysis/tests/utils/test_multistate.py b/src/openfe_analysis/tests/utils/test_multistate.py index ed9b81e..bc21dde 100644 --- a/src/openfe_analysis/tests/utils/test_multistate.py +++ b/src/openfe_analysis/tests/utils/test_multistate.py @@ -15,12 +15,16 @@ @pytest.fixture(scope='module') def dataset(simulation_nc): - return nc.Dataset(simulation_nc) + ds = nc.Dataset(simulation_nc) + yield ds + ds.close() @pytest.fixture(scope='module') def skipped_dataset(simulation_skipped_nc): - return nc.Dataset(simulation_skipped_nc) + ds = nc.Dataset(simulation_skipped_nc) + yield ds + ds.close() @pytest.mark.flaky(reruns=3) From 5dd31dd5f5ff0a5d61f5add555faeeac91900e64 Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 14:54:20 +0100 Subject: [PATCH 13/19] None safety --- src/openfe_analysis/reader.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/openfe_analysis/reader.py b/src/openfe_analysis/reader.py index b2bf23f..884550b 100644 --- a/src/openfe_analysis/reader.py +++ b/src/openfe_analysis/reader.py @@ -193,6 +193,7 @@ def _reopen(self): self._frame_index = -1 def close(self): - if self._dataset_owner: - self._dataset.close() - self._dataset = None + if self._dataset is not None: + if self._dataset_owner: + self._dataset.close() + self._dataset = None From 9439efdba8d3ed23440ba65dba85b0b2ba2d867f Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 14:57:22 +0100 Subject: [PATCH 14/19] disable some tests --- .../tests/utils/test_multistate.py | 82 ++++++++++--------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/src/openfe_analysis/tests/utils/test_multistate.py b/src/openfe_analysis/tests/utils/test_multistate.py index bc21dde..0eab99b 100644 --- a/src/openfe_analysis/tests/utils/test_multistate.py +++ b/src/openfe_analysis/tests/utils/test_multistate.py @@ -13,32 +13,32 @@ ) -@pytest.fixture(scope='module') -def dataset(simulation_nc): - ds = nc.Dataset(simulation_nc) - yield ds - ds.close() - - -@pytest.fixture(scope='module') -def skipped_dataset(simulation_skipped_nc): - ds = nc.Dataset(simulation_skipped_nc) - yield ds - ds.close() - - -@pytest.mark.flaky(reruns=3) -@pytest.mark.parametrize("state, frame, replica", [[0, 0, 0], [0, 1, 3], [0, -1, 7], [3, 100, 6]]) -def test_state_to_replica(dataset, state, frame, replica): - assert _state_to_replica(dataset, state, frame) == replica - - -@pytest.mark.flaky(reruns=3) -def test_replica_positions_at_frame(dataset): - pos = _replica_positions_at_frame(dataset, 1, -1) - assert_allclose( - pos[-3] * unit("nanometer"), np.array([0.6037003, 7.2835016, 5.804355]) * unit("nanometer") - ) +#@pytest.fixture(scope='module') +#def dataset(simulation_nc): +# ds = nc.Dataset(simulation_nc) +# yield ds +# ds.close() +# +# +#@pytest.fixture(scope='module') +#def skipped_dataset(simulation_skipped_nc): +# ds = nc.Dataset(simulation_skipped_nc) +# yield ds +# ds.close() +# +# +#@pytest.mark.flaky(reruns=3) +#@pytest.mark.parametrize("state, frame, replica", [[0, 0, 0], [0, 1, 3], [0, -1, 7], [3, 100, 6]]) +#def test_state_to_replica(dataset, state, frame, replica): +# assert _state_to_replica(dataset, state, frame) == replica +# +# +#@pytest.mark.flaky(reruns=3) +#def test_replica_positions_at_frame(dataset): +# pos = _replica_positions_at_frame(dataset, 1, -1) +# assert_allclose( +# pos[-3] * unit("nanometer"), np.array([0.6037003, 7.2835016, 5.804355]) * unit("nanometer") +# ) def test_create_new_dataset(tmpdir): @@ -78,17 +78,19 @@ def test_create_new_dataset(tmpdir): assert ds.variables["cell_angles"].get_dims()[1].name == "cell_angular" assert ds.variables["cell_angles"].dtype.name == "float64" - -def test_get_unitcell(dataset): - dims = _get_unitcell(dataset, 7, -1) - assert_allclose(dims, [82.12723, 82.12723, 82.12723, 90.0, 90.0, 90.0]) - - dims = _get_unitcell(dataset, 3, 1) - assert_allclose(dims, [82.191055, 82.191055, 82.191055, 90.0, 90.0, 90.0]) - - -def test_simulation_skipped_nc_no_positions_box_vectors_frame1( - skipped_dataset, -): - assert _get_unitcell(dataset, 1, 1) is None - assert dataset.variables["positions"][1][0].mask.all() + ds.close() + + +#def test_get_unitcell(dataset): +# dims = _get_unitcell(dataset, 7, -1) +# assert_allclose(dims, [82.12723, 82.12723, 82.12723, 90.0, 90.0, 90.0]) +# +# dims = _get_unitcell(dataset, 3, 1) +# assert_allclose(dims, [82.191055, 82.191055, 82.191055, 90.0, 90.0, 90.0]) +# +# +#def test_simulation_skipped_nc_no_positions_box_vectors_frame1( +# skipped_dataset, +#): +# assert _get_unitcell(dataset, 1, 1) is None +# assert dataset.variables["positions"][1][0].mask.all() From 0c95db8f05962d8a3ac7ff2deb7546bb7321e94d Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 15:45:56 +0100 Subject: [PATCH 15/19] try something --- .../tests/utils/test_multistate.py | 76 +++++++++---------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/src/openfe_analysis/tests/utils/test_multistate.py b/src/openfe_analysis/tests/utils/test_multistate.py index 0eab99b..78d67a3 100644 --- a/src/openfe_analysis/tests/utils/test_multistate.py +++ b/src/openfe_analysis/tests/utils/test_multistate.py @@ -13,32 +13,30 @@ ) -#@pytest.fixture(scope='module') -#def dataset(simulation_nc): -# ds = nc.Dataset(simulation_nc) -# yield ds -# ds.close() -# -# -#@pytest.fixture(scope='module') -#def skipped_dataset(simulation_skipped_nc): -# ds = nc.Dataset(simulation_skipped_nc) -# yield ds -# ds.close() -# -# -#@pytest.mark.flaky(reruns=3) -#@pytest.mark.parametrize("state, frame, replica", [[0, 0, 0], [0, 1, 3], [0, -1, 7], [3, 100, 6]]) -#def test_state_to_replica(dataset, state, frame, replica): -# assert _state_to_replica(dataset, state, frame) == replica -# -# -#@pytest.mark.flaky(reruns=3) -#def test_replica_positions_at_frame(dataset): -# pos = _replica_positions_at_frame(dataset, 1, -1) -# assert_allclose( -# pos[-3] * unit("nanometer"), np.array([0.6037003, 7.2835016, 5.804355]) * unit("nanometer") -# ) +@pytest.fixture(scope='module') +def dataset(simulation_nc): + ds = nc.Dataset(simulation_nc) + yield ds + ds.close() + + +@pytest.fixture(scope='module') +def skipped_dataset(simulation_skipped_nc): + ds = nc.Dataset(simulation_skipped_nc) + yield ds + ds.close() + + +@pytest.mark.parametrize("state, frame, replica", [[0, 0, 0], [0, 1, 3], [0, -1, 7], [3, 100, 6]]) +def test_state_to_replica(dataset, state, frame, replica): + assert _state_to_replica(dataset, state, frame) == replica + + +def test_replica_positions_at_frame(dataset): + pos = _replica_positions_at_frame(dataset, 1, -1) + assert_allclose( + pos[-3] * unit("nanometer"), np.array([0.6037003, 7.2835016, 5.804355]) * unit("nanometer") + ) def test_create_new_dataset(tmpdir): @@ -81,16 +79,16 @@ def test_create_new_dataset(tmpdir): ds.close() -#def test_get_unitcell(dataset): -# dims = _get_unitcell(dataset, 7, -1) -# assert_allclose(dims, [82.12723, 82.12723, 82.12723, 90.0, 90.0, 90.0]) -# -# dims = _get_unitcell(dataset, 3, 1) -# assert_allclose(dims, [82.191055, 82.191055, 82.191055, 90.0, 90.0, 90.0]) -# -# -#def test_simulation_skipped_nc_no_positions_box_vectors_frame1( -# skipped_dataset, -#): -# assert _get_unitcell(dataset, 1, 1) is None -# assert dataset.variables["positions"][1][0].mask.all() +def test_get_unitcell(dataset): + dims = _get_unitcell(dataset, 7, -1) + assert_allclose(dims, [82.12723, 82.12723, 82.12723, 90.0, 90.0, 90.0]) + + dims = _get_unitcell(dataset, 3, 1) + assert_allclose(dims, [82.191055, 82.191055, 82.191055, 90.0, 90.0, 90.0]) + + +def test_simulation_skipped_nc_no_positions_box_vectors_frame1( + skipped_dataset, +): + assert _get_unitcell(dataset, 1, 1) is None + assert dataset.variables["positions"][1][0].mask.all() From c762775a4ab03fd2663d9e644d470742b1a8b993 Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 15:47:33 +0100 Subject: [PATCH 16/19] reduce scope --- src/openfe_analysis/tests/utils/test_multistate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openfe_analysis/tests/utils/test_multistate.py b/src/openfe_analysis/tests/utils/test_multistate.py index 78d67a3..ac79661 100644 --- a/src/openfe_analysis/tests/utils/test_multistate.py +++ b/src/openfe_analysis/tests/utils/test_multistate.py @@ -13,14 +13,14 @@ ) -@pytest.fixture(scope='module') +@pytest.fixture() def dataset(simulation_nc): ds = nc.Dataset(simulation_nc) yield ds ds.close() -@pytest.fixture(scope='module') +@pytest.fixture() def skipped_dataset(simulation_skipped_nc): ds = nc.Dataset(simulation_skipped_nc) yield ds From 784df07909384d3d84e6a8be4143220e987299d8 Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 15:50:44 +0100 Subject: [PATCH 17/19] try pinning --- environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index 2a15530..2815e04 100644 --- a/environment.yml +++ b/environment.yml @@ -4,7 +4,7 @@ channels: dependencies: - click - MDAnalysis - - netCDF4 + - netCDF4 <1.7.1 - openff-units - pip - tqdm From 3f71be642575fd7010c46b66bc9730d72946b54f Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 15:52:14 +0100 Subject: [PATCH 18/19] remove -n call --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0160393..36a735f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -67,7 +67,7 @@ jobs: - name: "Run tests" run: | - pytest -n auto -v --cov=openfe_analysis --cov-report=xml --durations=10 + pytest -v --cov=openfe_analysis --cov-report=xml --durations=10 - name: "Save pooch test data cache" id: cache-testdata-save From 269acdaf43ac41eb676fc4214eab4ac2639f8fff Mon Sep 17 00:00:00 2001 From: IAlibay Date: Mon, 1 Sep 2025 15:54:27 +0100 Subject: [PATCH 19/19] fix typo --- src/openfe_analysis/tests/utils/test_multistate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openfe_analysis/tests/utils/test_multistate.py b/src/openfe_analysis/tests/utils/test_multistate.py index ac79661..69c5cb6 100644 --- a/src/openfe_analysis/tests/utils/test_multistate.py +++ b/src/openfe_analysis/tests/utils/test_multistate.py @@ -90,5 +90,5 @@ def test_get_unitcell(dataset): def test_simulation_skipped_nc_no_positions_box_vectors_frame1( skipped_dataset, ): - assert _get_unitcell(dataset, 1, 1) is None - assert dataset.variables["positions"][1][0].mask.all() + assert _get_unitcell(skipped_dataset, 1, 1) is None + assert skipped_dataset.variables["positions"][1][0].mask.all()