Skip to content

Commit 596cd7c

Browse files
IAlibayorbeckst
andauthored
mdakits are now optional deps (#4953)
* mdakits are now optional deps --------- Co-authored-by: Oliver Beckstein <orbeckst@gmail.com>
1 parent bd00f88 commit 596cd7c

File tree

12 files changed

+143
-72
lines changed

12 files changed

+143
-72
lines changed

.github/actions/build-src/action.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,6 @@ runs:
6666
micromamba info
6767
micromamba list
6868
69-
- name: mda_deps
70-
shell: bash -l {0}
71-
run: |
72-
# Install mdakit deps that depend on MDA
73-
python -m pip install --no-deps \
74-
waterdynamics \
75-
pathsimanalysis \
76-
mdahole2
77-
7869
- name: build_mda_main
7970
shell: bash -l {0}
8071
run: |

.github/actions/setup-deps/action.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,16 @@ inputs:
9696
# pip-install optional dependencies
9797
duecredit:
9898
default: 'duecredit'
99+
mdahole2:
100+
default: 'mdahole2'
99101
parmed:
100102
default: 'parmed'
103+
pathsimanalysis:
104+
default: 'pathsimanalysis'
101105
pyedr:
102106
default: 'pyedr>=0.7.0'
107+
waterdynamics:
108+
default: 'waterdynamics'
103109

104110
runs:
105111
using: "composite"

.github/workflows/gh-ci-cron.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ jobs:
6767
pytest \
6868
pytest-xdist \
6969
pytest-timeout
70-
# deps that depend on MDA
71-
python -m pip install --no-deps \
72-
waterdynamics \
73-
pathsimanalysis \
74-
mdahole2
7570
7671
- name: pre_install_list_deps
7772
run: python -m pip list

package/CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ Enhancements
3838

3939

4040
Changes
41+
* MDAnalysis.analysis.psa, MDAnalysis.analysis.waterdynamics and
42+
MDAnalysis.analysis.hole2 are now no longer available by default in
43+
MDAnalysis. You will need to install their respective MDAKits to
44+
keep using them. Please note that they will be fully removed in
45+
MDAnalysis v3.0 (Issue #4899, PR #4953).
4146
* Changed `fasteners` dependency to `filelock` (Issue #4797, PR #4800)
4247
* Codebase is now formatted with black (version `24`) (PR #4886)
4348

package/MDAnalysis/analysis/hole2/__init__.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,23 @@
3636
3737
"""
3838
import warnings
39-
from mdahole2.analysis.hole import hole, HoleAnalysis
40-
from mdahole2.analysis import utils, templates
41-
from mdahole2.analysis.utils import create_vmd_surface
4239

43-
wmsg = (
44-
"Deprecated in version 2.8.0\n"
45-
"MDAnalysis.analysis.hole2 is deprecated in favour of the "
46-
"MDAKit madahole2 (https://www.mdanalysis.org/mdahole2/) "
47-
"and will be removed in MDAnalysis version 3.0.0"
48-
)
49-
warnings.warn(wmsg, category=DeprecationWarning)
40+
try:
41+
from mdahole2.analysis.hole import hole, HoleAnalysis
42+
from mdahole2.analysis import utils, templates
43+
from mdahole2.analysis.utils import create_vmd_surface
44+
except ImportError:
45+
wmsg = (
46+
"Please install the mdahole2 mdakit to use it in MDAnalysis.\n"
47+
"More details can be found here: "
48+
"https://www.mdanalysis.org/mdahole2/getting_started.html"
49+
)
50+
warnings.warn(wmsg, category=UserWarning)
51+
else:
52+
wmsg = (
53+
"Deprecated in version 2.8.0\n"
54+
"MDAnalysis.analysis.hole2 is deprecated in favour of the "
55+
"MDAKit madahole2 (https://www.mdanalysis.org/mdahole2/) "
56+
"and will be removed in MDAnalysis version 3.0.0"
57+
)
58+
warnings.warn(wmsg, category=DeprecationWarning)

package/MDAnalysis/analysis/psa.py

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,35 @@
4646

4747
import warnings
4848

49-
from pathsimanalysis import (
50-
get_path_metric_func,
51-
sqnorm,
52-
get_msd_matrix,
53-
reshaper,
54-
get_coord_axes,
55-
hausdorff,
56-
hausdorff_wavg,
57-
hausdorff_avg,
58-
hausdorff_neighbors,
59-
discrete_frechet,
60-
dist_mat_to_vec,
61-
Path,
62-
PSAPair,
63-
PSAnalysis,
64-
)
65-
66-
67-
wmsg = (
68-
"Deprecation in version 2.8.0:\n"
69-
"MDAnalysis.analysis.psa is deprecated in favour of the MDAKit "
70-
"PathSimAnalysis (https://github.com/MDAnalysis/PathSimAnalysis) "
71-
"and will be removed in MDAnalysis version 3.0.0"
72-
)
73-
warnings.warn(wmsg, category=DeprecationWarning)
49+
try:
50+
from pathsimanalysis import (
51+
get_path_metric_func,
52+
sqnorm,
53+
get_msd_matrix,
54+
reshaper,
55+
get_coord_axes,
56+
hausdorff,
57+
hausdorff_wavg,
58+
hausdorff_avg,
59+
hausdorff_neighbors,
60+
discrete_frechet,
61+
dist_mat_to_vec,
62+
Path,
63+
PSAPair,
64+
PSAnalysis,
65+
)
66+
except ImportError:
67+
wmsg = (
68+
"Please install the PathSimAnalysis mdakit to use it in MDAnalysis.\n"
69+
"More details can be found here: "
70+
"https://www.mdanalysis.org/PathSimAnalysis/getting_started.html"
71+
)
72+
warnings.warn(wmsg, category=UserWarning)
73+
else:
74+
wmsg = (
75+
"Deprecation in version 2.8.0:\n"
76+
"MDAnalysis.analysis.psa is deprecated in favour of the MDAKit "
77+
"PathSimAnalysis (https://github.com/MDAnalysis/PathSimAnalysis) "
78+
"and will be removed in MDAnalysis version 3.0.0"
79+
)
80+
warnings.warn(wmsg, category=DeprecationWarning)

package/MDAnalysis/analysis/waterdynamics.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,25 @@
4141
"""
4242
import warnings
4343

44-
from waterdynamics.waterdynamics import (
45-
WaterOrientationalRelaxation,
46-
AngularDistribution,
47-
MeanSquareDisplacement,
48-
SurvivalProbability,
49-
)
50-
51-
52-
wmsg = (
53-
"Deprecation in version 2.8.0\n"
54-
"MDAnalysis.analysis.waterdynamics is deprecated in favour of the "
55-
"MDAKit waterdynamics (https://www.mdanalysis.org/waterdynamics/) "
56-
"and will be removed in MDAnalysis version 3.0.0"
57-
)
58-
warnings.warn(wmsg, category=DeprecationWarning)
44+
try:
45+
from waterdynamics.waterdynamics import (
46+
WaterOrientationalRelaxation,
47+
AngularDistribution,
48+
MeanSquareDisplacement,
49+
SurvivalProbability,
50+
)
51+
except ImportError:
52+
wmsg = (
53+
"Please install the waterdynamics mdakit to use it in MDAnalysis.\n"
54+
"More details can be found here: "
55+
"https://www.mdanalysis.org/waterdynamics/getting_started.html"
56+
)
57+
warnings.warn(wmsg, category=UserWarning)
58+
else:
59+
wmsg = (
60+
"Deprecation in version 2.8.0\n"
61+
"MDAnalysis.analysis.waterdynamics is deprecated in favour of the "
62+
"MDAKit waterdynamics (https://www.mdanalysis.org/waterdynamics/) "
63+
"and will be removed in MDAnalysis version 3.0.0"
64+
)
65+
warnings.warn(wmsg, category=DeprecationWarning)

package/pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ dependencies = [
4040
'packaging',
4141
'filelock',
4242
'mda-xdrlib',
43-
'waterdynamics',
44-
'pathsimanalysis',
45-
'mdahole2',
4643
]
4744
keywords = [
4845
"python", "science", "chemistry", "biophysics", "molecular-dynamics",
@@ -86,6 +83,9 @@ analysis = [
8683
"scikit-learn",
8784
"tidynamics>=1.0.0",
8885
'networkx>=2.0',
86+
'waterdynamics',
87+
'pathsimanalysis',
88+
'mdahole2',
8989
]
9090
doc = [
9191
"sphinx",

testsuite/MDAnalysisTests/analysis/test_hole2.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,24 @@
2626
import pytest
2727

2828
from MDAnalysis.analysis import hole2
29+
from MDAnalysisTests.util import import_not_available
2930

3031

32+
@pytest.mark.skipif(
33+
import_not_available("mdahole2"),
34+
reason="Test skipped because mdahole2 is not found",
35+
)
3136
def test_moved_to_mdakit_warning():
3237
wmsg = "MDAnalysis.analysis.hole2 is deprecated"
3338
with pytest.warns(DeprecationWarning, match=wmsg):
3439
reload(hole2)
40+
41+
42+
@pytest.mark.skipif(
43+
not import_not_available("mdahole2"),
44+
reason="Test skipped because mdahole2 is found",
45+
)
46+
def test_install_mdakit_warning():
47+
wmsg = "Please install"
48+
with pytest.warns(UserWarning, match=wmsg):
49+
reload(hole2)

testsuite/MDAnalysisTests/analysis/test_psa.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,24 @@
2525
import pytest
2626

2727
from MDAnalysis.analysis import psa
28+
from MDAnalysisTests.util import import_not_available
2829

2930

31+
@pytest.mark.skipif(
32+
import_not_available("pathsimanalysis"),
33+
reason="Test skipped because PathSimAnalysis is not found",
34+
)
3035
def test_moved_to_mdakit_warning():
3136
wmsg = "MDAnalysis.analysis.psa is deprecated in favour of the MDAKit"
3237
with pytest.warns(DeprecationWarning, match=wmsg):
3338
reload(psa)
39+
40+
41+
@pytest.mark.skipif(
42+
not import_not_available("pathsimanalysis"),
43+
reason="Test skipped because PathSimAnalysis is found",
44+
)
45+
def test_install_mdakit_warning():
46+
wmsg = "Please install"
47+
with pytest.warns(UserWarning, match=wmsg):
48+
reload(psa)

0 commit comments

Comments
 (0)