From f5b64b4e26ed9ba367e7264d090a8e807557741a Mon Sep 17 00:00:00 2001 From: Dominique Sydow Date: Fri, 26 Apr 2024 16:08:05 +0100 Subject: [PATCH 1/8] support Python 3.12 only --- .github/workflows/CI.yaml | 10 +++------- devtools/conda-envs/test_env.yaml | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index c96db5e..0244922 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -26,15 +26,11 @@ jobs: matrix: cfg: - os: ubuntu-latest - python-version: "3.8" - - os: ubuntu-latest - python-version: "3.9" - - os: ubuntu-latest - python-version: "3.10" + python-version: "3.12" - os: macos-latest - python-version: "3.8" + python-version: "3.12" - os: windows-latest - python-version: "3.8" + python-version: "3.12" steps: - uses: actions/checkout@v3 diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index d3ecb21..6634f2f 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -4,7 +4,7 @@ channels: - defaults dependencies: # Base depends - - python>=3.8 + - python>=3.12 - pip - numpy - pandas From 7fe7a372eedc09977e9138830e99091c877e9af6 Mon Sep 17 00:00:00 2001 From: Dominique Sydow Date: Fri, 26 Apr 2024 16:08:25 +0100 Subject: [PATCH 2/8] update versioneer wrt Python 3.12 --- versioneer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/versioneer.py b/versioneer.py index 64fea1c..3aa5da3 100644 --- a/versioneer.py +++ b/versioneer.py @@ -339,9 +339,9 @@ def get_config_from_root(root): # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") - parser = configparser.SafeConfigParser() + parser = configparser.ConfigParser() with open(setup_cfg, "r") as f: - parser.readfp(f) + parser.read_file(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): From f723cdbf9adbd011d267a1249f740e5b025be4cc Mon Sep 17 00:00:00 2001 From: Dominique Sydow Date: Fri, 26 Apr 2024 16:14:59 +0100 Subject: [PATCH 3/8] trigger CI From 0a73098feca6feafc135767056adefcba3231592 Mon Sep 17 00:00:00 2001 From: Dominique Sydow Date: Fri, 26 Apr 2024 16:17:46 +0100 Subject: [PATCH 4/8] update matplotlib style --- dynophores/viz/plot/static.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dynophores/viz/plot/static.py b/dynophores/viz/plot/static.py index 85846f6..7521972 100644 --- a/dynophores/viz/plot/static.py +++ b/dynophores/viz/plot/static.py @@ -10,7 +10,11 @@ from matplotlib import ticker import seaborn as sns -plt.style.use("seaborn") +try: + plt.style.use("seaborn") +except OSError: + # Needed for matplotlib>=3.8.0 + plt.style.use("seaborn-v0_8") def superfeatures_vs_envpartners(dynophore, superfeature_ids="all", annotate_heatmap=False): From 09b32af048d694e85460da19238f803ccffef49e Mon Sep 17 00:00:00 2001 From: Dominique Sydow Date: Fri, 26 Apr 2024 16:18:34 +0100 Subject: [PATCH 5/8] use Py 3.12 for linting and docs --- .github/workflows/CI.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 0244922..b011f5b 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -82,7 +82,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: [3.8] + python-version: [3.12] steps: - uses: actions/checkout@v3 @@ -129,7 +129,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: [3.8] + python-version: [3.12] steps: - uses: actions/checkout@v3 From f1796e69f169b39bdad640fe1245048ed1c3177c Mon Sep 17 00:00:00 2001 From: Dominique Sydow Date: Fri, 26 Apr 2024 16:21:33 +0100 Subject: [PATCH 6/8] run black with Py 3.12 --- dynophores/core/chemicalfeaturecloud3d.py | 8 +++++--- dynophores/core/dynophore.py | 8 +++++--- dynophores/core/superfeature.py | 6 +++--- dynophores/tests/core/test_ligand.py | 1 - dynophores/viz/view2d/static.py | 1 + 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/dynophores/core/chemicalfeaturecloud3d.py b/dynophores/core/chemicalfeaturecloud3d.py index 995db07..0d8318f 100644 --- a/dynophores/core/chemicalfeaturecloud3d.py +++ b/dynophores/core/chemicalfeaturecloud3d.py @@ -22,9 +22,11 @@ class ChemicalFeatureCloud3D: def __init__(self, center, points, **kwargs): self.center = center self.points = [ - point - if isinstance(point, ChemicalFeatureCloud3DPoint) - else ChemicalFeatureCloud3DPoint(**point) + ( + point + if isinstance(point, ChemicalFeatureCloud3DPoint) + else ChemicalFeatureCloud3DPoint(**point) + ) for point in points ] diff --git a/dynophores/core/dynophore.py b/dynophores/core/dynophore.py index c4c13d8..e796ebd 100644 --- a/dynophores/core/dynophore.py +++ b/dynophores/core/dynophore.py @@ -40,9 +40,11 @@ def __init__( self.id = id self.ligand = ligand if isinstance(ligand, Ligand) else Ligand(**ligand) self.superfeatures = { - superfeature_id: superfeature - if isinstance(superfeature, SuperFeature) - else SuperFeature(**superfeature) + superfeature_id: ( + superfeature + if isinstance(superfeature, SuperFeature) + else SuperFeature(**superfeature) + ) for superfeature_id, superfeature in superfeatures.items() } diff --git a/dynophores/core/superfeature.py b/dynophores/core/superfeature.py index c2fc7a0..8b32f2d 100644 --- a/dynophores/core/superfeature.py +++ b/dynophores/core/superfeature.py @@ -39,9 +39,9 @@ def __init__(self, id, feature_type, atom_numbers, occurrences, envpartners, col self.atom_numbers = atom_numbers self.occurrences = occurrences self.envpartners = { - envpartner_id: envpartner - if isinstance(envpartner, EnvPartner) - else EnvPartner(**envpartner) + envpartner_id: ( + envpartner if isinstance(envpartner, EnvPartner) else EnvPartner(**envpartner) + ) for envpartner_id, envpartner in envpartners.items() } self.color = color diff --git a/dynophores/tests/core/test_ligand.py b/dynophores/tests/core/test_ligand.py index 907412b..840e6c9 100644 --- a/dynophores/tests/core/test_ligand.py +++ b/dynophores/tests/core/test_ligand.py @@ -4,7 +4,6 @@ Uses fixture tests.conftest.envpartner. """ - from pathlib import Path from dynophores import parsers diff --git a/dynophores/viz/view2d/static.py b/dynophores/viz/view2d/static.py index 3b88da3..b65cf09 100644 --- a/dynophores/viz/view2d/static.py +++ b/dynophores/viz/view2d/static.py @@ -1,6 +1,7 @@ """ Contains RDKit ligand 2D visualizations (static). """ + from collections import defaultdict from rdkit import Geometry From 095c94a356ea93b79842926b8127b13bbebde519 Mon Sep 17 00:00:00 2001 From: Dominique Sydow Date: Fri, 26 Apr 2024 17:16:31 +0100 Subject: [PATCH 7/8] clean up flake8 linting issues --- dynophores/cli.py | 32 ++++++++++++++-------------- dynophores/viz/view3d/interactive.py | 2 ++ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/dynophores/cli.py b/dynophores/cli.py index 7600dbf..59e8ee8 100644 --- a/dynophores/cli.py +++ b/dynophores/cli.py @@ -102,7 +102,7 @@ def _greet(): with open(logo_path, "r", encoding="ascii") as f: print(f.read()) title_str = f"Dynophores CLI {_version.get_versions()['version']}" - print(f"\n{title_str:^64}") + print(f"\n{title_str: ^64}") def _create_viz(args): @@ -114,16 +114,16 @@ def _create_viz(args): dyno_path = Path(args.dyno) if not dyno_path.is_dir(): - raise RuntimeError(f"Input is no file or file does not exist: `{dyno_path.absolute()}`") + raise RuntimeError(f"Input is no file or file does not exist: {dyno_path.absolute()}") pdb_path = Path(args.pdb) if not pdb_path.is_file(): - raise RuntimeError(f"Input is no file or file does not exist: `{pdb_path.absolute()}`") + raise RuntimeError(f"Input is no file or file does not exist: {pdb_path.absolute()}") if args.dcd is not None: dcd_path = Path(args.dcd) if not dcd_path.is_file(): - raise RuntimeError(f"Input is no file or file does not exist: `{dcd_path.absolute()}`") + raise RuntimeError(f"Input is no file or file does not exist: {dcd_path.absolute()}") else: dcd_path = None @@ -168,8 +168,8 @@ def _copy_notebook(new_notebook_path): new_notebook_path = Path(new_notebook_path) if new_notebook_path.suffix != ".ipynb": raise RuntimeError( - f"Input file path must have suffix `.ipynb`. " - f"Your input: `{new_notebook_path.absolute()}`" + f"Input file path must have suffix .ipynb. " + f"Your input: {new_notebook_path.absolute()}" ) if not new_notebook_path.exists(): new_notebook_path.parent.mkdir(parents=True, exist_ok=True) @@ -179,16 +179,16 @@ def _copy_notebook(new_notebook_path): print("\nCopy dynophore notebook to user workspace...") copyfile(template_notebook_path, new_notebook_path) if new_notebook_path.exists(): - print(f"Dynophore notebook location: `{new_notebook_path.absolute()}`") + print(f"Dynophore notebook location: {new_notebook_path.absolute()}") else: raise RuntimeError( f"Could not create dynophore notebook at selected location " - f"`{new_notebook_path.absolute()}`" + f"{new_notebook_path.absolute()}" ) else: raise RuntimeError( f"Could not find dynophore notebook at expected location " - f"`{template_notebook_path.absolute()}`." + f"{template_notebook_path.absolute()}." ) @@ -200,20 +200,20 @@ def _update_paths_in_notebook(notebook_path, dyno_path, pdb_path, dcd_path=None) notebook_path = Path(notebook_path) if not notebook_path.is_file(): - raise RuntimeError(f"Input is no file or does not exist: `{notebook_path.absolute()}`") + raise RuntimeError(f"Input is no file or does not exist: {notebook_path.absolute()}") dyno_path = Path(dyno_path) if not dyno_path.is_dir(): - raise RuntimeError(f"Input is no file or file does not exist: `{dyno_path.absolute()}`") + raise RuntimeError(f"Input is no file or file does not exist: {dyno_path.absolute()}") pdb_path = Path(pdb_path) if not pdb_path.is_file(): - raise RuntimeError(f"Input is no file or file does not exist: `{pdb_path.absolute()}`") + raise RuntimeError(f"Input is no file or file does not exist: {pdb_path.absolute()}") if dcd_path is not None: dcd_path = Path(dcd_path) if not dcd_path.is_file(): - raise RuntimeError(f"Input is no file or file does not exist: `{dcd_path.absolute()}`") + raise RuntimeError(f"Input is no file or file does not exist: {dcd_path.absolute()}") # Replace template filepaths in notebook with user-defined filepaths print("\nUpdate filepaths in notebook to user filepaths...") @@ -260,12 +260,12 @@ def _open_notebook(notebook_path): notebook_path = Path(notebook_path) if not notebook_path.exists(): - raise RuntimeError(f"Input path does not exist: `{notebook_path.absolute()}`") + raise RuntimeError(f"Input path does not exist: {notebook_path.absolute()}") if not notebook_path.is_file(): - raise RuntimeError(f"Input path is not a file: `{notebook_path.absolute()}`") + raise RuntimeError(f"Input path is not a file: {notebook_path.absolute()}") if notebook_path.suffix != ".ipynb": raise RuntimeError( - f"Input file path must have suffix `.ipynb`. Your input: `{notebook_path.absolute()}`" + f"Input file path must have suffix .ipynb. Your input: {notebook_path.absolute()}" ) print("Open dynophore notebook with Jupyter Lab...") diff --git a/dynophores/viz/view3d/interactive.py b/dynophores/viz/view3d/interactive.py index 65fd5db..4ac7206 100644 --- a/dynophores/viz/view3d/interactive.py +++ b/dynophores/viz/view3d/interactive.py @@ -2,6 +2,8 @@ Contains NGLview 3D visualizations. """ +# flake8: noqa + import warnings import numpy as np From 52b57b8606f5638219ab7fa9eab7ac863df8a907 Mon Sep 17 00:00:00 2001 From: Dominique Sydow Date: Fri, 26 Apr 2024 17:19:42 +0100 Subject: [PATCH 8/8] drop support for black-nb and flake8-nb --- .github/workflows/CI.yaml | 12 ------------ devtools/conda-envs/test_env.yaml | 3 --- 2 files changed, 15 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index b011f5b..0a14109 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -111,18 +111,6 @@ jobs: run: | flake8 --config setup.cfg dynophores - - name: Run black-nb check - shell: bash -l {0} - run: | - black-nb --check -l 99 docs/tutorials/*.ipynb - black-nb --check -l 99 dynophores/notebooks/*.ipynb - - - name: Run flake8-nb - shell: bash -l {0} - run: | - flake8-nb --config setup.cfg docs/tutorials/*.ipynb - flake8-nb --config setup.cfg dynophores/notebooks/*.ipynb - docs: name: Docs test on ${{ matrix.os }}, Python ${{ matrix.python-version }} runs-on: ${{ matrix.os }} diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index 6634f2f..a272e97 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -32,6 +32,3 @@ dependencies: # Developement - black - flake8 - - pip: - - black-nb - - flake8-nb