From 01ff52b4860fb32f907ea94298132c06cc158750 Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Fri, 31 May 2024 16:46:32 -0400 Subject: [PATCH 1/5] bump min ASE to 3.23.0 just released https://pypi.org/project/ase/3.23.0 --- .github/workflows/test.yml | 3 --- chgnet/model/dynamics.py | 30 +++++++++--------------------- examples/basics.ipynb | 3 +-- pyproject.toml | 17 ++++++++++------- 4 files changed, 20 insertions(+), 33 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 479b7f9a..25ec9503 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,9 +38,6 @@ jobs: uv pip install -e .[test] --system - # TODO remove next line installing ase from main branch when FrechetCellFilter is released - uv pip install --upgrade 'ase@git+https://gitlab.com/ase/ase' --system - - name: Run Tests run: pytest --capture=no --cov --cov-report=xml env: diff --git a/chgnet/model/dynamics.py b/chgnet/model/dynamics.py index b41aba6a..31a3ad33 100644 --- a/chgnet/model/dynamics.py +++ b/chgnet/model/dynamics.py @@ -242,13 +242,13 @@ def relax( Default = True ase_filter (str | ase.filters.Filter): The filter to apply to the atoms object for relaxation. Default = FrechetCellFilter - Used to default to ExpCellFilter but was removed due to bug reported in - https://gitlab.com/ase/ase/-/issues/1321 and fixed in + Default used to be ExpCellFilter which was removed due to bug reported + in https://gitlab.com/ase/ase/-/issues/1321 and fixed in https://gitlab.com/ase/ase/-/merge_requests/3024. save_path (str | None): The path to save the trajectory. Default = None - loginterval (int | None): Interval for logging trajectory and crystal feas - Default = 1 + loginterval (int | None): Interval for logging trajectory and crystal + features. Default = 1 crystal_feas_save_path (str | None): Path to save crystal feature vectors which are logged at a loginterval rage Default = None @@ -262,30 +262,18 @@ def relax( dict[str, Structure | TrajectoryObserver]: A dictionary with 'final_structure' and 'trajectory'. """ - try: - import ase.filters as filter_classes - from ase.filters import Filter - - except ImportWarning: - import ase.constraints as filter_classes - from ase.constraints import Filter - - if ase_filter == "FrechetCellFilter": - ase_filter = "ExpCellFilter" - print( - "Failed to import ase.filters. Default filter to ExpCellFilter. " - "For better relaxation accuracy with the new FrechetCellFilter, " - "run pip install git+https://gitlab.com/ase/ase" - ) + import ase.filters as filters + from ase.filters import Filter + valid_filter_names = [ name - for name, cls in inspect.getmembers(filter_classes, inspect.isclass) + for name, cls in inspect.getmembers(filters, inspect.isclass) if issubclass(cls, Filter) ] if isinstance(ase_filter, str): if ase_filter in valid_filter_names: - ase_filter = getattr(filter_classes, ase_filter) + ase_filter = getattr(filters, ase_filter) else: raise ValueError( f"Invalid {ase_filter=}, must be one of {valid_filter_names}. " diff --git a/examples/basics.ipynb b/examples/basics.ipynb index 7b0101d3..814c299c 100644 --- a/examples/basics.ipynb +++ b/examples/basics.ipynb @@ -19,8 +19,7 @@ " from chgnet.model import CHGNet\n", "except ImportError:\n", " # install CHGNet (only needed on Google Colab or if you didn't install CHGNet yet)\n", - " !pip install chgnet\n", - " !pip install git+https://gitlab.com/ase/ase" + " !pip install chgnet" ] }, { diff --git a/pyproject.toml b/pyproject.toml index ab1e324c..7764f980 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,3 @@ -[build-system] -requires = ["Cython", "setuptools>=65.0", "wheel"] -build-backend = "setuptools.build_meta" - [project] name = "chgnet" version = "0.3.6" @@ -11,7 +7,7 @@ requires-python = ">=3.9" readme = "README.md" license = { text = "Modified BSD" } dependencies = [ - "ase", + "ase>=3.23.0", "cython>=0.29.26", "numpy>=1.21.6", "nvidia-ml-py3>=7.352.0", @@ -48,9 +44,14 @@ find = { include = ["chgnet*"], exclude = ["tests", "tests*"] } "chgnet" = ["*.json"] "chgnet.pretrained" = ["*", "**/*"] +[build-system] +requires = ["Cython", "setuptools>=65.0", "wheel"] +build-backend = "setuptools.build_meta" + [tool.ruff] target-version = "py39" -include = ["**/pyproject.toml", "*.ipynb", "*.py", "*.pyi"] +extend-include = ["*.ipynb"] + [tool.ruff.lint] select = ["ALL"] ignore = [ @@ -90,6 +91,9 @@ pydocstyle.convention = "google" isort.required-imports = ["from __future__ import annotations"] isort.split-on-trailing-comma = false +[tool.ruff.format] +docstring-code-format = true + [tool.ruff.lint.per-file-ignores] "site/*" = ["INP001", "S602"] "tests/*" = ["ANN201", "D100", "D103", "FBT001", "FBT002", "INP001", "S101"] @@ -98,7 +102,6 @@ isort.split-on-trailing-comma = false "chgnet/**/*" = ["T201"] "__init__.py" = ["F401"] - [tool.coverage.run] source = ["chgnet"] From 79b78c013b05a39f7917d17ce66ff5b9406f04ab Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Fri, 31 May 2024 17:37:35 -0400 Subject: [PATCH 2/5] test both lowest-direct and highest uv package resolutions --- .github/workflows/test.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 25ec9503..c4fabe05 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,9 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, macos-14, windows-latest] - python-version: ["3.10", "3.12"] + version: + - { python: "3.10", resolution: highest } + - { python: "3.12", resolution: lowest-direct } runs-on: ${{ matrix.os }} steps: @@ -23,7 +25,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.version.python }} cache: pip cache-dependency-path: pyproject.toml @@ -36,7 +38,7 @@ jobs: python setup.py build_ext --inplace - uv pip install -e .[test] --system + uv pip install -e .[test] --system --resolution=${{ matrix.version.resolution }} - name: Run Tests run: pytest --capture=no --cov --cov-report=xml From 5d74c9bce5bc67cdab5e68f47e5ee5ac91771c9c Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Fri, 31 May 2024 17:43:52 -0400 Subject: [PATCH 3/5] pyproject up-pin optional dependencies --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7764f980..a4bc5c0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,10 +28,10 @@ classifiers = [ ] [project.optional-dependencies] -test = ["pytest", "pytest-cov"] +test = ["pytest-cov>=4", "pytest>=8"] # needed to run interactive example notebooks -examples = ["crystal-toolkit", "pandas"] -docs = ["lazydocs"] +examples = ["crystal-toolkit>=2023.11.3", "pandas>=2"] +docs = ["lazydocs>=0.4"] [project.urls] Source = "https://github.com/CederGroupHub/chgnet" From 4b8e54b7e34d83a25c9bba373e4c4c388d731a6e Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Fri, 31 May 2024 17:48:02 -0400 Subject: [PATCH 4/5] update min pandas to 2.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a4bc5c0e..d538bf40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ classifiers = [ [project.optional-dependencies] test = ["pytest-cov>=4", "pytest>=8"] # needed to run interactive example notebooks -examples = ["crystal-toolkit>=2023.11.3", "pandas>=2"] +examples = ["crystal-toolkit>=2023.11.3", "pandas>=2.2"] docs = ["lazydocs>=0.4"] [project.urls] From ab7b60a3d1b2468a8404bce11d1b333f4b701431 Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Fri, 31 May 2024 17:51:12 -0400 Subject: [PATCH 5/5] numpy>=1.26 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d538bf40..4421b354 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ license = { text = "Modified BSD" } dependencies = [ "ase>=3.23.0", "cython>=0.29.26", - "numpy>=1.21.6", + "numpy>=1.26", "nvidia-ml-py3>=7.352.0", "pymatgen>=2023.10.11", "torch>=1.11.0",