Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump min ASE to 3.23.0 #159

Merged
merged 5 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -36,10 +38,7 @@ jobs:

python setup.py build_ext --inplace

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
uv pip install -e .[test] --system --resolution=${{ matrix.version.resolution }}

- name: Run Tests
run: pytest --capture=no --cov --cov-report=xml
Expand Down
30 changes: 9 additions & 21 deletions chgnet/model/dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}. "
Expand Down
3 changes: 1 addition & 2 deletions examples/basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
25 changes: 14 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[build-system]
requires = ["Cython", "setuptools>=65.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "chgnet"
version = "0.3.6"
Expand All @@ -11,9 +7,9 @@ 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",
"numpy>=1.26",
"nvidia-ml-py3>=7.352.0",
"pymatgen>=2023.10.11",
"torch>=1.11.0",
Expand All @@ -32,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.2"]
docs = ["lazydocs>=0.4"]

[project.urls]
Source = "https://github.com/CederGroupHub/chgnet"
Expand All @@ -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 = [
Expand Down Expand Up @@ -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"]
Expand All @@ -98,7 +102,6 @@ isort.split-on-trailing-comma = false
"chgnet/**/*" = ["T201"]
"__init__.py" = ["F401"]


[tool.coverage.run]
source = ["chgnet"]

Expand Down
Loading