Skip to content

Commit

Permalink
Drop Python 3.9 support (#377)
Browse files Browse the repository at this point in the history
* Drop Python 3.9

* Apply ruff safe fixes

* Apply ruff unsafe fixes

* Apply manual ruff fixes

* Update docs

* Drop upper Python limit

* Use strict for all zips

* Add missing future annotations

* Revert "Implement temporary fix for CI (#376)"

This reverts commit fe6e6d9.

* Drop Python 3.9 from Mac CI

* Apply new ruff fixes
  • Loading branch information
ElliottKasoar authored Jan 17, 2025
1 parent 4c3fb95 commit d4d4b32
Show file tree
Hide file tree
Showing 26 changed files with 92 additions and 114 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
python-version: ['3.9','3.10','3.11','3.12']
python-version: ["3.10","3.11","3.12"]

steps:
- uses: actions/checkout@v4
Expand All @@ -27,9 +27,7 @@ jobs:
env:
# show timings of tests
PYTEST_ADDOPTS: "--durations=0"
run: |
unset CI
uv run pytest --run-extra-mlips --cov janus_core --cov-append .
run: uv run pytest --run-extra-mlips --cov janus_core --cov-append .

- name: Report coverage to Coveralls
uses: coverallsapp/github-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
python-version: ['3.9','3.10','3.11','3.12']
python-version: ["3.10","3.11","3.12"]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Tools for machine learnt interatomic potentials

`janus-core` dependencies currently include:

- Python >= 3.9
- Python >= 3.10
- ASE >= 3.23
- mace-torch = 0.3.8
- chgnet = 0.3.8 (optional)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting_started/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Dependencies

``janus-core`` dependencies currently include:

- Python >= 3.9
- Python >= 3.10
- ASE >= 3.23
- mace-torch = 0.3.8
- chgnet = 0.3.8 (optional)
Expand Down
4 changes: 3 additions & 1 deletion janus_core/calculations/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ def run(self) -> EoSResults:
if self.write_results:
with open(f"{self.file_prefix}-eos-raw.dat", "w", encoding="utf8") as out:
print("#Lattice Scalar | Energy [eV] | Volume [Å^3] ", file=out)
for eos_data in zip(self.lattice_scalars, self.energies, self.volumes):
for eos_data in zip(
self.lattice_scalars, self.energies, self.volumes, strict=True
):
print(*eos_data, file=out)

eos = EquationOfState(self.volumes, self.energies, self.eos_type)
Expand Down
3 changes: 2 additions & 1 deletion janus_core/calculations/geom_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from __future__ import annotations

from typing import Any, Callable
from collections.abc import Callable
from typing import Any
import warnings

from ase import Atoms, filters, units
Expand Down
9 changes: 3 additions & 6 deletions janus_core/cli/descriptors.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# ruff: noqa: I002, FA100
"""Set up MLIP descriptors commandline interface."""

# Issues with future annotations and typer
# c.f. https://github.com/maxb2/typer-config/issues/295
# from __future__ import annotations
from __future__ import annotations

from pathlib import Path
from typing import Annotated, Optional
from typing import Annotated

from typer import Context, Option, Typer
from typer_config import use_config
Expand Down Expand Up @@ -49,7 +46,7 @@ def descriptors(
device: Device = "cpu",
model_path: ModelPath = None,
out: Annotated[
Optional[Path],
Path | None,
Option(
help=(
"Path to save structure with calculated descriptors. Default is "
Expand Down
9 changes: 3 additions & 6 deletions janus_core/cli/eos.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# ruff: noqa: I002, FA100
"""Set up eos commandline interface."""

# Issues with future annotations and typer
# c.f. https://github.com/maxb2/typer-config/issues/295
# from __future__ import annotations
from __future__ import annotations

from pathlib import Path
from typing import Annotated, Optional, get_args
from typing import Annotated, get_args

from typer import Context, Option, Typer
from typer_config import use_config
Expand Down Expand Up @@ -66,7 +63,7 @@ def eos(
read_kwargs: ReadKwargsLast = None,
calc_kwargs: CalcKwargs = None,
file_prefix: Annotated[
Optional[Path],
Path | None,
Option(
help=(
"""
Expand Down
15 changes: 6 additions & 9 deletions janus_core/cli/geomopt.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# ruff: noqa: I002, FA100
"""Set up geomopt commandline interface."""

# Issues with future annotations and typer
# c.f. https://github.com/maxb2/typer-config/issues/295
# from __future__ import annotations
from __future__ import annotations

from pathlib import Path
from typing import Annotated, Any, Optional
from typing import Annotated, Any

from typer import Context, Option, Typer
from typer_config import use_config
Expand All @@ -30,7 +27,7 @@

def _set_minimize_kwargs(
minimize_kwargs: dict[str, Any],
traj: Optional[str],
traj: str | None,
opt_cell_lengths: bool,
pressure: float,
) -> None:
Expand Down Expand Up @@ -91,7 +88,7 @@ def geomopt(
ctx: Context,
struct: StructPath,
optimizer: Annotated[
Optional[str],
str | None,
Option(help="Name of ASE optimizer function to use."),
] = "LBFGS",
fmax: Annotated[
Expand All @@ -112,7 +109,7 @@ def geomopt(
),
] = False,
filter_func: Annotated[
Optional[str],
str | None,
Option(
help=(
"Name of ASE filter/constraint function to use. If using "
Expand All @@ -134,7 +131,7 @@ def geomopt(
),
] = 0.001,
out: Annotated[
Optional[Path],
Path | None,
Option(
help=(
"Path to save optimized structure. Default is inferred from name "
Expand Down
7 changes: 2 additions & 5 deletions janus_core/cli/janus.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# ruff: noqa: I002, FA100
"""Set up commandline interface."""

# Issues with future annotations and typer
# c.f. https://github.com/maxb2/typer-config/issues/295
# from __future__ import annotations
from __future__ import annotations

from typing import Annotated

Expand Down Expand Up @@ -39,7 +36,7 @@ def print_version(
version: Annotated[
bool, Option("--version", help="Print janus version and exit.")
] = None,
) -> False:
) -> None:
"""
Print current janus-core version and exit.
Expand Down
27 changes: 12 additions & 15 deletions janus_core/cli/md.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# ruff: noqa: I002, FA100
"""Set up md commandline interface."""

# Issues with future annotations and typer
# c.f. https://github.com/maxb2/typer-config/issues/295
# from __future__ import annotations
from __future__ import annotations

from pathlib import Path
from typing import Annotated, Optional, get_args
from typing import Annotated, get_args

from typer import Context, Option, Typer
from typer_config import use_config
Expand Down Expand Up @@ -101,7 +98,7 @@ def md(
int, Option(help="Frequency to rescale velocities during equilibration.")
] = 10,
file_prefix: Annotated[
Optional[Path],
Path | None,
Option(
help=(
"""
Expand All @@ -116,7 +113,7 @@ def md(
bool, Option(help="Whether to infer restart file if restarting dynamics.")
] = True,
restart_stem: Annotated[
Optional[Path],
Path | None,
Option(help="Stem for restart file name. Default inferred from `file_prefix`."),
] = None,
restart_every: Annotated[
Expand All @@ -129,7 +126,7 @@ def md(
int, Option(help="Restart files to keep if rotating.")
] = 4,
final_file: Annotated[
Optional[Path],
Path | None,
Option(
help=(
"""
Expand All @@ -140,7 +137,7 @@ def md(
),
] = None,
stats_file: Annotated[
Optional[Path],
Path | None,
Option(
help=(
"""
Expand All @@ -152,7 +149,7 @@ def md(
] = None,
stats_every: Annotated[int, Option(help="Frequency to output statistics.")] = 100,
traj_file: Annotated[
Optional[Path],
Path | None,
Option(help="File to save trajectory. Default inferred from `file_prefix`."),
] = None,
traj_append: Annotated[bool, Option(help="Whether to append trajectory.")] = False,
Expand All @@ -161,23 +158,23 @@ def md(
int, Option(help="Frequency of steps to save trajectory.")
] = 100,
temp_start: Annotated[
Optional[float],
float | None,
Option(help="Temperature to start heating, in K."),
] = None,
temp_end: Annotated[
Optional[float],
float | None,
Option(help="Maximum temperature for heating, in K."),
] = None,
temp_step: Annotated[
Optional[float], Option(help="Size of temperature steps when heating, in K.")
float | None, Option(help="Size of temperature steps when heating, in K.")
] = None,
temp_time: Annotated[
Optional[float], Option(help="Time between heating steps, in fs.")
float | None, Option(help="Time between heating steps, in fs.")
] = None,
write_kwargs: WriteKwargs = None,
post_process_kwargs: PostProcessKwargs = None,
seed: Annotated[
Optional[int],
int | None,
Option(help="Random seed for numpy.random and random functions."),
] = None,
log: LogPath = None,
Expand Down
11 changes: 4 additions & 7 deletions janus_core/cli/phonons.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# ruff: noqa: I002, FA100
"""Set up phonons commandline interface."""

# Issues with future annotations and typer
# c.f. https://github.com/maxb2/typer-config/issues/295
# from __future__ import annotations
from __future__ import annotations

from pathlib import Path
from typing import Annotated, Optional
from typing import Annotated

from typer import Context, Option, Typer
from typer_config import use_config
Expand Down Expand Up @@ -67,7 +64,7 @@ def phonons(
),
] = 51,
qpoint_file: Annotated[
Optional[Path],
Path | None,
Option(
help=(
"Path to yaml file with info to generate a path of q-points for band "
Expand Down Expand Up @@ -125,7 +122,7 @@ def phonons(
read_kwargs: ReadKwargsLast = None,
calc_kwargs: CalcKwargs = None,
file_prefix: Annotated[
Optional[Path],
Path | None,
Option(
help=(
"""
Expand Down
5 changes: 1 addition & 4 deletions janus_core/cli/preprocess.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# noqa: I002, FA102
"""Set up MLIP preprocessing commandline interface."""

# Issues with future annotations and typer
# c.f. https://github.com/maxb2/typer-config/issues/295
# from __future__ import annotations
from __future__ import annotations

from pathlib import Path
from typing import Annotated
Expand Down
11 changes: 4 additions & 7 deletions janus_core/cli/singlepoint.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# ruff: noqa: I002, FA100
"""Set up singlepoint commandline interface."""

# Issues with future annotations and typer
# c.f. https://github.com/maxb2/typer-config/issues/295
# from __future__ import annotations
from __future__ import annotations

from pathlib import Path
from typing import Annotated, Optional
from typing import Annotated

from typer import Context, Option, Typer
from typer_config import use_config
Expand Down Expand Up @@ -37,7 +34,7 @@ def singlepoint(
device: Device = "cpu",
model_path: ModelPath = None,
properties: Annotated[
Optional[list[str]],
list[str] | None,
Option(
help=(
"Properties to calculate. If not specified, 'energy', 'forces' "
Expand All @@ -46,7 +43,7 @@ def singlepoint(
),
] = None,
out: Annotated[
Optional[Path],
Path | None,
Option(
help=(
"Path to save structure with calculated results. Default is inferred "
Expand Down
5 changes: 1 addition & 4 deletions janus_core/cli/train.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# noqa: I002, FA102
"""Set up MLIP training commandline interface."""

# Issues with future annotations and typer
# c.f. https://github.com/maxb2/typer-config/issues/295
# from __future__ import annotations
from __future__ import annotations

from pathlib import Path
from typing import Annotated
Expand Down
Loading

0 comments on commit d4d4b32

Please sign in to comment.