Skip to content

Commit

Permalink
Bump min supported Python to 3.10 (#992)
Browse files Browse the repository at this point in the history
* obj.__class__.__name__ -> type(maker).__name__

* bump ruff target-version to py310 and fix errors

* pyproject bump requires-python = ">=3.9", testing.yml drop 3.9 CI, README.md add badge showing min supported Python version

* missed some python-version: 3.9 in GH wfs

* fix outdated docs saying atomate2 supports py3.8+

* add Python 3.12 to supported versions and test in CI

* fix multiple level 1 headings in docs/user/codes/openmm.md

* quippy-ase==0.9.14; python_version < '3.12'

* "tblite>=0.3.0; python_version < '3.12'"

* try zip(strict=True) everywhere

* ruff

---------

Co-authored-by: Alex Ganose <[email protected]>
  • Loading branch information
janosh and utf authored Sep 26, 2024
1 parent 79aaf15 commit 96b2b82
Show file tree
Hide file tree
Showing 48 changed files with 158 additions and 130 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.10"
cache: pip
cache-dependency-path: pyproject.toml

Expand All @@ -36,7 +36,7 @@ jobs:
shell: bash -l {0} # enables conda/mamba env activation by reading bash profile
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]

steps:
- name: Check out repo
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
shell: bash -l {0} # enables conda/mamba env activation by reading bash profile
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]

steps:
- name: Check out repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.10"

- name: Install pre-commit
run: pip install pre-commit
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
exclude: ^(.github/|tests/test_data/abinit/)
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.6.1
rev: v0.6.7
hooks:
- id: ruff
args: [--fix]
Expand All @@ -30,7 +30,7 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.1
rev: v1.11.2
hooks:
- id: mypy
files: ^src/
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![pypi version](https://img.shields.io/pypi/v/atomate2?color=blue)](https://pypi.org/project/atomate2)
![supported python versions](https://img.shields.io/pypi/pyversions/atomate2)
[![Zenodo](https://img.shields.io/badge/DOI-10.5281/zenodo.10677081-blue?logo=Zenodo&logoColor=white)](https://zenodo.org/records/10677081)
[![This project supports Python 3.10+](https://img.shields.io/badge/Python-3.10+-blue.svg?logo=python&logoColor=white)](https://python.org/downloads)

[Documentation][docs] | [PyPI][pypi] | [GitHub][github]

Expand Down Expand Up @@ -85,7 +86,7 @@ atomate2 workflows can be run using the [FireWorks] software. See the

## Installation

Atomate2 is a Python 3.8+ library and can be installed using pip. Full installation
Atomate2 is a Python 3.10+ library and can be installed using pip. Full installation
and configuration instructions are provided in the [installation tutorial][installation].

## Tutorials
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("https://docs.python.org/3.8", None),
"python": ("https://docs.python.org/3.10", None),
"matplotlib": ("https://matplotlib.org/stable/", None),
"networkx": ("https://networkx.org/documentation/stable/", None),
"jobflow": ("https://materialsproject.github.io/jobflow", None),
Expand Down
30 changes: 14 additions & 16 deletions docs/user/codes/openmm.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
>>> conda activate atomate2

# installing atomate2
>>> pip install git+https://github.com/orionarcher/atomate2.git
>>> pip install git+https://github.com/orionarcher/atomate2

# installing classical_md dependencies
>>> conda install -c conda-forge --file .github/classical_md_requirements.txt
Expand All @@ -18,7 +18,7 @@ you can clone the repository and install from source.

``` bash
# installing atomate2
>>> git clone https://github.com/orionarcher/atomate2.git
>>> git clone https://github.com/orionarcher/atomate2
>>> cd atomate2
>>> git branch openff
>>> git checkout openff
Expand All @@ -33,7 +33,7 @@ you intend to run on GPU, make sure that the tests are passing for CUDA.
>>> python -m openmm.testInstallation
```

# Understanding Atomate2 OpenMM
## Understanding Atomate2 OpenMM

Atomate2 is really just a collection of jobflow workflows relevant to
materials science. In all the workflows, we pass our system of interest
Expand All @@ -55,7 +55,6 @@ The first job we need to create generates the `Interchange` object.
To specify the system of interest, we use give it the SMILES strings,
counts, and names (optional) of the molecules we want to include.


```python
from atomate2.openff.core import generate_interchange

Expand All @@ -73,7 +72,6 @@ out the `create_mol_spec` function in the `atomate2.openff.utils`
module. Under the hood, this is being called on each mol_spec dict.
Meaning the code below is functionally identical to the code above.


```python
from atomate2.openff.utils import create_mol_spec

Expand All @@ -90,7 +88,6 @@ object, which we can pass to the next stage of the simulation.
NOTE: It's actually mandatory to include partial charges
for PF6- here, the built in partial charge method fails.


```python
import numpy as np
from pymatgen.core.structure import Molecule
Expand Down Expand Up @@ -205,13 +202,13 @@ Awesome! At this point, we've run a workflow and could start analyzing
our data. Before we get there though, let's go through some of the
other simulation options available.

# Digging Deeper
## Digging Deeper

Atomate2 OpenMM supports running a variety of workflows with different
configurations. Below we dig in to some of the more advanced options.


### Configuring the Simulation

<details>
<summary>Learn more about the configuration of OpenMM simulations</summary>

Expand All @@ -228,14 +225,13 @@ once and have it apply to all stages of the simulation. The value inheritance
is as follows: 1) any explicitly set value, 2) the value from the previous
maker, 3) the default value (as shown below).


```python
from atomate2.openmm.jobs.base import OPENMM_MAKER_DEFAULTS

print(OPENMM_MAKER_DEFAULTS)
```

```
```py
{
"step_size": 0.001,
"temperature": 298,
Expand Down Expand Up @@ -339,7 +335,6 @@ Rather than use `jobflow.yaml`, you could also create the stores in
Python and pass the stores to the `run_locally` function. This is a bit
more code, so usually the prior method is preferred.


```python
from jobflow import run_locally, JobStore
from maggma.stores import MongoStore, S3Store
Expand Down Expand Up @@ -374,19 +369,18 @@ run_locally(
ensure_success=True,
)
```

</details>

### Running on GPUs

<details>
<summary>Learn to accelerate MD simulations with GPUs</summary>


Running on a GPU is nearly as simple as running on a CPU. The only difference
is that you need to specify the `platform_properties` argument in the
`EnergyMinimizationMaker` with the `DeviceIndex` of the GPU you want to use.


```python
production_maker = OpenMMFlowMaker(
name="test_production",
Expand Down Expand Up @@ -414,7 +408,6 @@ First you'll need to install mpi4py.

Then you can modify and run the following script to distribute the work across the GPUs.


```python
# other imports
Expand Down Expand Up @@ -457,15 +450,16 @@ for i in range(4):
# this script will run four times, each with a different rank, thus distributing the work across the four GPUs.
run_locally(flows[rank], ensure_success=True)
```

</details>

# Analysis with Emmet
## Analysis with Emmet

For now, you'll need to make sure you have a particular emmet branch installed.
Later the builders will be integrated into `main`.

```bash
pip install git+https://github.com/orionarcher/emmet.git@md_builders
pip install git+https://github.com/orionarcher/emmet@md_builders
```

### Analyzing Local Data
Expand Down Expand Up @@ -498,6 +492,7 @@ u = create_universe(
solute = create_solute(u, solute_name="Li", networking_solvents=["PF6"])
```

</details>

### Setting up builders
Expand Down Expand Up @@ -556,6 +551,7 @@ builder.connect()
<summary>Here are some more convenient queries.</summary>

Here are some more convenient queries we could use!

```python
# query jobs from a specific day
april_16 = {"completed_at": {"$regex": "^2024-04-16"}}
Expand All @@ -570,6 +566,7 @@ job_uuids = [
]
my_specific_jobs = {"uuid": {"$in": job_uuids}}
```

</details>

</details>
Expand Down Expand Up @@ -611,6 +608,7 @@ solute = create_solute(
fallback_radius=3,
)
```

</details>

### Automated analysis with builders
Expand Down
4 changes: 2 additions & 2 deletions docs/user/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ atomate2
## Create a conda environment

```{note}
Make sure to create a Python 3.8+ environment as recent versions of atomate2 only
support Python 3.8 and higher.
Make sure to create a Python 3.10+ environment as recent versions of atomate2 only
support Python 3.10 and higher.
```

We highly recommend that you organize your installation of the atomate2 and the other
Expand Down
35 changes: 17 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.12",
"Topic :: Other/Nonlisted Topic",
"Topic :: Scientific/Engineering",
]
requires-python = ">=3.9"
requires-python = ">=3.10"
dependencies = [
"PyYAML",
"click",
Expand Down Expand Up @@ -54,21 +54,19 @@ forcefields = [
"calorine<=2.2.1",
"chgnet>=0.2.2",
"mace-torch>=0.3.3",
"torchdata<=0.7.1", # TODO: remove when issue fixed
"matgl>=1.1.3",
"quippy-ase>=0.9.14",
# quippy-ase support for py3.12 tracked in https://github.com/libAtoms/QUIP/issues/645
"quippy-ase>=0.9.14; python_version < '3.12'",
"sevenn>=0.9.3",
"torchdata<=0.7.1", # TODO: remove when issue fixed
]
ase = [
"ase>=3.23.0",
]
ase-ext = [
"tblite>=0.3.0",
]
ase = ["ase>=3.23.0"]
# tblite py3.12 support tracked in https://github.com/tblite/tblite/issues/198
ase-ext = ["tblite>=0.3.0; python_version < '3.12'"]
openmm = [
"mdanalysis>=2.7.0",
"openmm>=8.1.0",
"openmm-mdanalysis-reporter>=0.1.0",
"openmm>=8.1.0",
]
docs = [
"FireWorks==2.0.3",
Expand Down Expand Up @@ -101,31 +99,31 @@ strict = [
"ijson==3.3.0",
"jobflow==0.1.18",
"lobsterpy==0.4.5",
"mdanalysis==2.7.0",
"monty==2024.7.30",
"mp-api==0.42.2",
"numpy",
"openmm-mdanalysis-reporter==0.1.0",
"openmm==8.1.1",
"phonopy==2.27.0",
"pydantic-settings==2.5.2",
"pydantic==2.9.2",
"pymatgen-analysis-defects==2024.7.19",
"pymatgen==2024.6.10",
"python-ulid==2.7.0",
"seekpath==2.1.0",
"tblite==0.3.0",
"tblite==0.3.0; python_version < '3.12'",
"typing-extensions==4.12.2",
"mdanalysis==2.7.0",
"openmm==8.1.1",
"openmm-mdanalysis-reporter==0.1.0",
]
strict-forcefields = [
"calorine==2.2.1",
"chgnet==0.3.8",
"mace-torch>=0.3.3",
"torchdata==0.7.1", # TODO: remove when issue fixed
"matgl==1.1.3",
"quippy-ase==0.9.14",
"quippy-ase==0.9.14; python_version < '3.12'",
"sevenn==0.9.3.post1",
"torch==2.2.1",
"torchdata==0.7.1", # TODO: remove when issue fixed
]

[project.scripts]
Expand Down Expand Up @@ -179,7 +177,8 @@ exclude_lines = [
]

[tool.ruff]
target-version = "py39"
target-version = "py310"
output-format = "concise"

[tool.ruff.lint]
select = ["ALL"]
Expand Down
6 changes: 3 additions & 3 deletions src/atomate2/abinit/sets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
from dataclasses import dataclass, field
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

import numpy as np
from abipy.abio.inputs import AbinitInput, MultiDataset
Expand Down Expand Up @@ -39,7 +39,7 @@
)

if TYPE_CHECKING:
from collections.abc import Iterable, Sequence
from collections.abc import Callable, Iterable, Sequence

from pymatgen.core.structure import Structure

Expand Down Expand Up @@ -394,7 +394,7 @@ def check_format_prev_dirs(
"""Check and format the prev_dirs (restart or dependency)."""
if prev_dirs is None:
return None
if isinstance(prev_dirs, (str, Path)):
if isinstance(prev_dirs, str | Path):
return [str(prev_dirs)]
return [str(prev_dir) for prev_dir in prev_dirs]

Expand Down
4 changes: 3 additions & 1 deletion src/atomate2/abinit/sets/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Callable
from typing import TYPE_CHECKING

import numpy as np
from abipy.abio.factories import (
Expand All @@ -18,6 +18,8 @@
from atomate2.abinit.sets.base import AbinitInputGenerator

if TYPE_CHECKING:
from collections.abc import Callable

from abipy.abio.inputs import AbinitInput
from pymatgen.core import Structure
from pymatgen.io.abinit import PseudoTable
Expand Down
Loading

0 comments on commit 96b2b82

Please sign in to comment.