From 0d022180bf0fbdf4939668196d1f25b9fede6d16 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:30:13 +0100 Subject: [PATCH 01/13] Update pyproject.toml changes fasteners to filelock dependency --- package/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/pyproject.toml b/package/pyproject.toml index 4dc2275df4..52275513d4 100644 --- a/package/pyproject.toml +++ b/package/pyproject.toml @@ -38,7 +38,7 @@ dependencies = [ 'tqdm>=4.43.0', 'threadpoolctl', 'packaging', - 'fasteners', + 'filelock', 'mda-xdrlib', 'waterdynamics', 'pathsimanalysis', From 833f58beb007f5a90f8a56e4368d30191d6e2342 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:30:52 +0100 Subject: [PATCH 02/13] Update requirements.txt changes fasteners to filelock dependency --- package/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/requirements.txt b/package/requirements.txt index accac1b49f..a196a9fe0f 100644 --- a/package/requirements.txt +++ b/package/requirements.txt @@ -1,7 +1,7 @@ biopython>=1.80 codecov cython -fasteners +filelock griddataformats gsd hypothesis From 0e45f80a8840db83896a386e6cc950d472178ae9 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:32:47 +0100 Subject: [PATCH 03/13] Update action.yaml changes in the action the fasteners dependency to filelock --- .github/actions/setup-deps/action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup-deps/action.yaml b/.github/actions/setup-deps/action.yaml index cbfd91df7e..3e34d24870 100644 --- a/.github/actions/setup-deps/action.yaml +++ b/.github/actions/setup-deps/action.yaml @@ -21,8 +21,8 @@ inputs: default: 'codecov' cython: default: 'cython' - fasteners: - default: 'fasteners' + filelock: + default: 'filelock' griddataformats: default: 'griddataformats' gsd: From 0505cc5ed34445874be308a0891a02e97b659ca5 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:33:32 +0100 Subject: [PATCH 04/13] Update action.yaml adjusted input fasteners to filelock --- .github/actions/setup-deps/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-deps/action.yaml b/.github/actions/setup-deps/action.yaml index 3e34d24870..91dd56b6d7 100644 --- a/.github/actions/setup-deps/action.yaml +++ b/.github/actions/setup-deps/action.yaml @@ -110,7 +110,7 @@ runs: CONDA_MIN_DEPS: | ${{ inputs.codecov }} ${{ inputs.cython }} - ${{ inputs.fasteners }} + ${{ inputs.filelock }} ${{ inputs.griddataformats }} ${{ inputs.hypothesis }} ${{ inputs.matplotlib }} From ea5a61c9e19d8bb804076a20ca29869577b6f25f Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:37:47 +0100 Subject: [PATCH 05/13] Update environment.yml changed fasteners to filelock --- maintainer/conda/environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maintainer/conda/environment.yml b/maintainer/conda/environment.yml index cd324d25cd..3ceeeadb2d 100644 --- a/maintainer/conda/environment.yml +++ b/maintainer/conda/environment.yml @@ -7,7 +7,7 @@ dependencies: - codecov - cython - docutils - - fasteners + - filelock - griddataformats - gsd - h5py>=2.10 From 40251b68325e9f6b83fb0be7f2adf626dc3609a5 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:38:13 +0100 Subject: [PATCH 06/13] Update azure-pipelines.yml changed fasteners to filelock --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 27b1c0db3f..20a32d103e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -90,7 +90,7 @@ jobs: scikit-learn tqdm threadpoolctl - fasteners + filelock displayName: 'Install dependencies' # for wheel install testing, we pin to an # older NumPy, the oldest version we support and that From c98a11fd706b615bd7987e1214f7dd52232c0dc1 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:41:25 +0100 Subject: [PATCH 07/13] Update XDR.py changed fasteners to filelock --- package/MDAnalysis/coordinates/XDR.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/package/MDAnalysis/coordinates/XDR.py b/package/MDAnalysis/coordinates/XDR.py index 6fe75982cc..0596241533 100644 --- a/package/MDAnalysis/coordinates/XDR.py +++ b/package/MDAnalysis/coordinates/XDR.py @@ -38,7 +38,7 @@ import numpy as np from os.path import getctime, getsize, isfile, split, join import warnings -import fasteners +from filelock import FileLock from . import base from ..lib.mdamath import triclinic_box @@ -121,6 +121,8 @@ class XDRBaseReader(base.ReaderBase): Add a InterProcessLock when generating offsets .. versionchanged:: 2.4.0 Use a direct read into ts attributes + .. versionchanged:: 2.9.0 + Changed fasteners.InterProcessLock() to filelock.FileLock """ @store_init_arguments def __init__(self, filename, convert_units=True, sub=None, @@ -195,7 +197,7 @@ def _load_offsets(self): # check if the location of the lock is writable. try: - with fasteners.InterProcessLock(lock_name) as filelock: + with FileLock(lock_name) as filelock: pass except OSError as e: if isinstance(e, PermissionError) or e.errno == errno.EROFS: @@ -206,7 +208,7 @@ def _load_offsets(self): else: raise - with fasteners.InterProcessLock(lock_name) as filelock: + with FileLock(lock_name) as filelock: if not isfile(fname): self._read_offsets(store=True) return From 97927bb681d6a41cbeec272eb884a9c3591a16dc Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Sat, 23 Nov 2024 01:49:31 +0100 Subject: [PATCH 08/13] Update XDR.py test _read_offsets adjustment --- package/MDAnalysis/coordinates/XDR.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package/MDAnalysis/coordinates/XDR.py b/package/MDAnalysis/coordinates/XDR.py index 0596241533..dbdfe68ab6 100644 --- a/package/MDAnalysis/coordinates/XDR.py +++ b/package/MDAnalysis/coordinates/XDR.py @@ -201,9 +201,7 @@ def _load_offsets(self): pass except OSError as e: if isinstance(e, PermissionError) or e.errno == errno.EROFS: - warnings.warn(f"Cannot write lock/offset file in same location as " - f"{self.filename}. Using slow offset calculation.") - self._read_offsets(store=True) + self._read_offsets(store=False) return else: raise From f8f05f29afbf0f14e8b08b5ee36ae89c9328b93f Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Sat, 23 Nov 2024 02:08:41 +0100 Subject: [PATCH 09/13] Update test_xdr.py modification of test_offset_lock_created to adjust to new dependency --- testsuite/MDAnalysisTests/coordinates/test_xdr.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_xdr.py b/testsuite/MDAnalysisTests/coordinates/test_xdr.py index efb15d7825..f3277b6174 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_xdr.py +++ b/testsuite/MDAnalysisTests/coordinates/test_xdr.py @@ -923,8 +923,7 @@ def test_persistent_offsets_readonly(self, tmpdir): shutil.rmtree(tmpdir) def test_offset_lock_created(self): - assert os.path.exists(XDR.offsets_filename(self.filename, - ending='lock')) + assert os.path.exists(XDR.offsets_filename(self.filename)) class TestXTCReader_offsets(_GromacsReader_offsets): From 3cd7307878899d39bb4fdc03b3b76c98fd3091ba Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Sat, 23 Nov 2024 02:48:55 +0100 Subject: [PATCH 10/13] Update XDR.py returned the warning and read_offsets for tests --- package/MDAnalysis/coordinates/XDR.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package/MDAnalysis/coordinates/XDR.py b/package/MDAnalysis/coordinates/XDR.py index dbdfe68ab6..0596241533 100644 --- a/package/MDAnalysis/coordinates/XDR.py +++ b/package/MDAnalysis/coordinates/XDR.py @@ -201,7 +201,9 @@ def _load_offsets(self): pass except OSError as e: if isinstance(e, PermissionError) or e.errno == errno.EROFS: - self._read_offsets(store=False) + warnings.warn(f"Cannot write lock/offset file in same location as " + f"{self.filename}. Using slow offset calculation.") + self._read_offsets(store=True) return else: raise From b66e3d21680909f4b4a15379d77602090f879fd0 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Sat, 23 Nov 2024 03:28:00 +0100 Subject: [PATCH 11/13] Update test_xdr.py required removal of asser_equal to not get the error, since now the files, dont't end with lock and the removal of the end would be a duplicate of the other assert_equal --- testsuite/MDAnalysisTests/coordinates/test_xdr.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_xdr.py b/testsuite/MDAnalysisTests/coordinates/test_xdr.py index f3277b6174..908c9be9a8 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_xdr.py +++ b/testsuite/MDAnalysisTests/coordinates/test_xdr.py @@ -907,9 +907,6 @@ def test_persistent_offsets_readonly(self, tmpdir): pytest.warns(UserWarning, match="Cannot write")): self._reader(filename) assert_equal(os.path.exists(XDR.offsets_filename(filename)), False) - # check the lock file is not created as well. - assert_equal(os.path.exists(XDR.offsets_filename(filename, - ending='.lock')), False) # pre-teardown permission fix - leaving permission blocked dir # is problematic on py3.9 + Windows it seems. See issue From e71943f64fa3fafe9029d39b6d2a7f7101c2e649 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:04:06 +0100 Subject: [PATCH 12/13] Update XDR.py changed read offsets from True to False, retained the warning --- package/MDAnalysis/coordinates/XDR.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/MDAnalysis/coordinates/XDR.py b/package/MDAnalysis/coordinates/XDR.py index 0596241533..bf036e34e5 100644 --- a/package/MDAnalysis/coordinates/XDR.py +++ b/package/MDAnalysis/coordinates/XDR.py @@ -203,7 +203,7 @@ def _load_offsets(self): if isinstance(e, PermissionError) or e.errno == errno.EROFS: warnings.warn(f"Cannot write lock/offset file in same location as " f"{self.filename}. Using slow offset calculation.") - self._read_offsets(store=True) + self._read_offsets(store=False) return else: raise From ce3656a0ccfe8e70bcffc61acc14e70498bc1b94 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:51:09 +0100 Subject: [PATCH 13/13] Update test_xdr.py changed and to or pytest warning in test --- testsuite/MDAnalysisTests/coordinates/test_xdr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_xdr.py b/testsuite/MDAnalysisTests/coordinates/test_xdr.py index 908c9be9a8..6f768cd6e1 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_xdr.py +++ b/testsuite/MDAnalysisTests/coordinates/test_xdr.py @@ -903,7 +903,7 @@ def test_persistent_offsets_readonly(self, tmpdir): filename = str(tmpdir.join(os.path.basename(self.filename))) # try to write a offsets file - with (pytest.warns(UserWarning, match="Couldn't save offsets") and + with (pytest.warns(UserWarning, match="Couldn't save offsets") or pytest.warns(UserWarning, match="Cannot write")): self._reader(filename) assert_equal(os.path.exists(XDR.offsets_filename(filename)), False)