Skip to content

Commit

Permalink
breaking: drop Python 3.8 support (#4185)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

- **New Features**
- Introduced new functionality for handling input data conversion
between different versions.
- Added `EnvMatStatSe` class for enhanced environmental matrix
statistics calculations.
- Implemented a mechanism to track the status of atoms (real vs.
virtual) in `BaseAtomicModel`.

- **Bug Fixes**
- Updated Python version requirements across documentation and
configuration files to Python 3.9 or above.

- **Documentation**
- Updated installation guides to reflect the new Python version
requirement and clarified virtual environment setup instructions.

- **Chores**
- Refined dependency management in `pyproject.toml` to support newer
Python versions and improve version control.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
njzjz and pre-commit-ci[bot] authored Oct 6, 2024
1 parent 7ce5b03 commit 192a97a
Show file tree
Hide file tree
Showing 237 changed files with 1,612 additions and 2,065 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
group: [1, 2, 3, 4, 5, 6]
python: ["3.8", "3.12"]
python: ["3.9", "3.12"]

steps:
- uses: actions/checkout@v4
Expand All @@ -34,7 +34,7 @@ jobs:
# existing TensorFlow package. Currently, it uses
# TensorFlow in the build dependency, but if it
# changes, setting `TENSORFLOW_ROOT`.
TENSORFLOW_VERSION: ${{ matrix.python == '3.8' && '2.13.1' || '2.16.1' }}
TENSORFLOW_VERSION: 2.16.1
DP_ENABLE_PYTORCH: 1
DP_BUILD_TESTING: 1
UV_EXTRA_INDEX_URL: "https://pypi.anaconda.org/njzjz/simple https://pypi.anaconda.org/mpi4py/simple"
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.8", "3.12"]
python: ["3.9", "3.12"]
needs: testpython
steps:
- name: Get durations from cache
Expand Down
10 changes: 3 additions & 7 deletions backend/dp_backend.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
"""A PEP-517 backend to find TensorFlow."""

from typing import (
List,
)

from scikit_build_core import build as _orig

from .find_pytorch import (
Expand All @@ -26,7 +22,7 @@
]


def __dir__() -> List[str]:
def __dir__() -> list[str]:
return __all__


Expand All @@ -42,7 +38,7 @@ def __dir__() -> List[str]:

def get_requires_for_build_wheel(
config_settings: dict,
) -> List[str]:
) -> list[str]:
return (
_orig.get_requires_for_build_wheel(config_settings)
+ find_tensorflow()[1]
Expand All @@ -52,7 +48,7 @@ def get_requires_for_build_wheel(

def get_requires_for_build_editable(
config_settings: dict,
) -> List[str]:
) -> list[str]:
return (
_orig.get_requires_for_build_editable(config_settings)
+ find_tensorflow()[1]
Expand Down
6 changes: 2 additions & 4 deletions backend/dynamic_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
Path,
)
from typing import (
Dict,
List,
Optional,
)

Expand All @@ -27,13 +25,13 @@
__all__ = ["dynamic_metadata"]


def __dir__() -> List[str]:
def __dir__() -> list[str]:
return __all__


def dynamic_metadata(
field: str,
settings: Optional[Dict[str, object]] = None,
settings: Optional[dict[str, object]] = None,
):
assert field in ["optional-dependencies", "entry-points", "scripts"]
_, _, find_libpython_requires, extra_scripts, tf_version, pt_version = (
Expand Down
4 changes: 1 addition & 3 deletions backend/find_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
get_path,
)
from typing import (
List,
Optional,
Tuple,
Union,
)

Expand All @@ -30,7 +28,7 @@


@lru_cache
def find_pytorch() -> Tuple[Optional[str], List[str]]:
def find_pytorch() -> tuple[Optional[str], list[str]]:
"""Find PyTorch library.
Tries to find PyTorch in the order of:
Expand Down
4 changes: 1 addition & 3 deletions backend/find_tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
get_path,
)
from typing import (
List,
Optional,
Tuple,
Union,
)

Expand All @@ -29,7 +27,7 @@


@lru_cache
def find_tensorflow() -> Tuple[Optional[str], List[str]]:
def find_tensorflow() -> tuple[Optional[str], list[str]]:
"""Find TensorFlow library.
Tries to find TensorFlow in the order of:
Expand Down
5 changes: 1 addition & 4 deletions backend/read_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
from functools import (
lru_cache,
)
from typing import (
Tuple,
)

from packaging.version import (
Version,
Expand All @@ -24,7 +21,7 @@


@lru_cache
def get_argument_from_env() -> Tuple[str, list, list, dict, str, str]:
def get_argument_from_env() -> tuple[str, list, list, dict, str, str]:
"""Get the arguments from environment variables.
The environment variables are assumed to be not changed during the build.
Expand Down
17 changes: 7 additions & 10 deletions deepmd/backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
TYPE_CHECKING,
Callable,
ClassVar,
Dict,
List,
Type,
)

from deepmd.utils.plugin import (
Expand Down Expand Up @@ -45,7 +42,7 @@ class Backend(PluginVariant, make_plugin_registry("backend")):
"""

@staticmethod
def get_backend(key: str) -> Type["Backend"]:
def get_backend(key: str) -> type["Backend"]:
"""Get the backend by key.
Parameters
Expand All @@ -61,7 +58,7 @@ def get_backend(key: str) -> Type["Backend"]:
return Backend.get_class_by_type(key)

@staticmethod
def get_backends() -> Dict[str, Type["Backend"]]:
def get_backends() -> dict[str, type["Backend"]]:
"""Get all the registered backend names.
Returns
Expand All @@ -74,7 +71,7 @@ def get_backends() -> Dict[str, Type["Backend"]]:
@staticmethod
def get_backends_by_feature(
feature: "Backend.Feature",
) -> Dict[str, Type["Backend"]]:
) -> dict[str, type["Backend"]]:
"""Get all the registered backend names with a specific feature.
Parameters
Expand All @@ -94,7 +91,7 @@ def get_backends_by_feature(
}

@staticmethod
def detect_backend_by_model(filename: str) -> Type["Backend"]:
def detect_backend_by_model(filename: str) -> type["Backend"]:
"""Detect the backend of the given model file.
Parameters
Expand Down Expand Up @@ -128,7 +125,7 @@ class Feature(Flag):

features: ClassVar[Feature] = Feature(0)
"""The features of the backend."""
suffixes: ClassVar[List[str]] = []
suffixes: ClassVar[list[str]] = []
"""The supported suffixes of the saved model.
The first element is considered as the default suffix."""
Expand Down Expand Up @@ -157,7 +154,7 @@ def entry_point_hook(self) -> Callable[["Namespace"], None]:

@property
@abstractmethod
def deep_eval(self) -> Type["DeepEvalBackend"]:
def deep_eval(self) -> type["DeepEvalBackend"]:
"""The Deep Eval backend of the backend.
Returns
Expand All @@ -169,7 +166,7 @@ def deep_eval(self) -> Type["DeepEvalBackend"]:

@property
@abstractmethod
def neighbor_stat(self) -> Type["NeighborStat"]:
def neighbor_stat(self) -> type["NeighborStat"]:
"""The neighbor statistics of the backend.
Returns
Expand Down
8 changes: 3 additions & 5 deletions deepmd/backend/dpmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
TYPE_CHECKING,
Callable,
ClassVar,
List,
Type,
)

from deepmd.backend.backend import (
Expand Down Expand Up @@ -37,7 +35,7 @@ class DPModelBackend(Backend):
Backend.Feature.DEEP_EVAL | Backend.Feature.NEIGHBOR_STAT | Backend.Feature.IO
)
"""The features of the backend."""
suffixes: ClassVar[List[str]] = [".dp", ".yaml", ".yml"]
suffixes: ClassVar[list[str]] = [".dp", ".yaml", ".yml"]
"""The suffixes of the backend."""

def is_available(self) -> bool:
Expand All @@ -62,7 +60,7 @@ def entry_point_hook(self) -> Callable[["Namespace"], None]:
raise NotImplementedError(f"Unsupported backend: {self.name}")

@property
def deep_eval(self) -> Type["DeepEvalBackend"]:
def deep_eval(self) -> type["DeepEvalBackend"]:
"""The Deep Eval backend of the backend.
Returns
Expand All @@ -77,7 +75,7 @@ def deep_eval(self) -> Type["DeepEvalBackend"]:
return DeepEval

@property
def neighbor_stat(self) -> Type["NeighborStat"]:
def neighbor_stat(self) -> type["NeighborStat"]:
"""The neighbor statistics of the backend.
Returns
Expand Down
8 changes: 3 additions & 5 deletions deepmd/backend/jax.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
TYPE_CHECKING,
Callable,
ClassVar,
List,
Type,
)

from deepmd.backend.backend import (
Expand Down Expand Up @@ -41,7 +39,7 @@ class JAXBackend(Backend):
# | Backend.Feature.IO
)
"""The features of the backend."""
suffixes: ClassVar[List[str]] = []
suffixes: ClassVar[list[str]] = []
"""The suffixes of the backend."""

def is_available(self) -> bool:
Expand All @@ -66,7 +64,7 @@ def entry_point_hook(self) -> Callable[["Namespace"], None]:
raise NotImplementedError

@property
def deep_eval(self) -> Type["DeepEvalBackend"]:
def deep_eval(self) -> type["DeepEvalBackend"]:
"""The Deep Eval backend of the backend.
Returns
Expand All @@ -77,7 +75,7 @@ def deep_eval(self) -> Type["DeepEvalBackend"]:
raise NotImplementedError

@property
def neighbor_stat(self) -> Type["NeighborStat"]:
def neighbor_stat(self) -> type["NeighborStat"]:
"""The neighbor statistics of the backend.
Returns
Expand Down
8 changes: 3 additions & 5 deletions deepmd/backend/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
TYPE_CHECKING,
Callable,
ClassVar,
List,
Type,
)

from deepmd.backend.backend import (
Expand Down Expand Up @@ -41,7 +39,7 @@ class PyTorchBackend(Backend):
| Backend.Feature.IO
)
"""The features of the backend."""
suffixes: ClassVar[List[str]] = [".pth", ".pt"]
suffixes: ClassVar[list[str]] = [".pth", ".pt"]
"""The suffixes of the backend."""

def is_available(self) -> bool:
Expand All @@ -68,7 +66,7 @@ def entry_point_hook(self) -> Callable[["Namespace"], None]:
return deepmd_main

@property
def deep_eval(self) -> Type["DeepEvalBackend"]:
def deep_eval(self) -> type["DeepEvalBackend"]:
"""The Deep Eval backend of the backend.
Returns
Expand All @@ -81,7 +79,7 @@ def deep_eval(self) -> Type["DeepEvalBackend"]:
return DeepEvalPT

@property
def neighbor_stat(self) -> Type["NeighborStat"]:
def neighbor_stat(self) -> type["NeighborStat"]:
"""The neighbor statistics of the backend.
Returns
Expand Down
3 changes: 1 addition & 2 deletions deepmd/backend/suffix.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
)
from typing import (
Optional,
Type,
Union,
)

Expand All @@ -18,7 +17,7 @@
def format_model_suffix(
filename: str,
feature: Optional[Backend.Feature] = None,
preferred_backend: Optional[Union[str, Type["Backend"]]] = None,
preferred_backend: Optional[Union[str, type["Backend"]]] = None,
strict_prefer: Optional[bool] = None,
) -> str:
"""Check and format the suffixes of a filename.
Expand Down
8 changes: 3 additions & 5 deletions deepmd/backend/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
TYPE_CHECKING,
Callable,
ClassVar,
List,
Type,
)

from deepmd.backend.backend import (
Expand Down Expand Up @@ -41,7 +39,7 @@ class TensorFlowBackend(Backend):
| Backend.Feature.IO
)
"""The features of the backend."""
suffixes: ClassVar[List[str]] = [".pb"]
suffixes: ClassVar[list[str]] = [".pb"]
"""The suffixes of the backend."""

def is_available(self) -> bool:
Expand Down Expand Up @@ -77,7 +75,7 @@ def entry_point_hook(self) -> Callable[["Namespace"], None]:
return deepmd_main

@property
def deep_eval(self) -> Type["DeepEvalBackend"]:
def deep_eval(self) -> type["DeepEvalBackend"]:
"""The Deep Eval backend of the backend.
Returns
Expand All @@ -90,7 +88,7 @@ def deep_eval(self) -> Type["DeepEvalBackend"]:
return DeepEvalTF

@property
def neighbor_stat(self) -> Type["NeighborStat"]:
def neighbor_stat(self) -> type["NeighborStat"]:
"""The neighbor statistics of the backend.
Returns
Expand Down
Loading

0 comments on commit 192a97a

Please sign in to comment.