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 supported Python to 3.10 #992

Merged
merged 13 commits into from
Sep 26, 2024
Merged
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a second python badge still listing 3.9.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that badge pulls the data it displays from PyPI, so will auto-update once this PR is merged and released

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oki, good to know :)

[![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
24 changes: 11 additions & 13 deletions docs/user/codes/openmm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,9 +450,10 @@ 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`.
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
27 changes: 12 additions & 15 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,17 @@ 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",
"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"]
ase-ext = ["tblite>=0.3.0"]
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,9 +97,12 @@ 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",
Expand All @@ -113,19 +112,16 @@ strict = [
"seekpath==2.1.0",
"tblite==0.3.0",
"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",
"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 +175,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
4 changes: 2 additions & 2 deletions src/atomate2/abinit/utils/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def log_initialization(
self, job: Job | Flow, initialization_info: Any | None = None
) -> None:
"""Log initialization information about the job."""
details = {"job_class": job.__class__.__name__}
details = {"job_class": type(job).__name__}
if initialization_info:
details["initialization_info"] = initialization_info
self.append(JobEvent(JobEvent.INITIALIZED, details=details))
Expand Down Expand Up @@ -187,7 +187,7 @@ def get_events_by_types(self, types: list | AbinitEvent) -> list:
types
Single type or list of types.
"""
types = types if isinstance(types, (list, tuple)) else [types]
types = types if isinstance(types, list | tuple) else [types]

return [e for e in self if e.event_type in types]

Expand Down
2 changes: 1 addition & 1 deletion src/atomate2/aims/utils/bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def prepare_band_input(structure: Structure, density: float = 20) -> list:
points, labels = bp.get_kpoints(line_density=density, coords_are_cartesian=False)
lines_and_labels: list[_SegmentDict] = []
current_segment: _SegmentDict | None = None
for label_, coords in zip(labels, points):
for label_, coords in zip(labels, points, strict=False):
# rename the Gamma point label
label = "G" if label_ in ("GAMMA", "\\Gamma", "Γ") else label_
if label:
Expand Down
Loading
Loading