Skip to content

Commit eccf075

Browse files
authored
Run CI with two different uv resolution strategies: highest and lowest-direct (#3852)
* fix typing_extensions ImportError #3752 (comment) * bump min ase to 3.23.0 * test both lowest-direct and highest uv package resolutions in CI * establish some loose lower bounds on all deps needed for deps install with --resolution=lowest-direct to work * netcdf4>=1.6 * pin chgnet==0.3.6 * try chgnet==0.3.5 * bump pre-commit hooks * imperative doc strings * doc str white space * test_string->test_str * ruff auto fixes * matgl>=1.1.1 numba>=0.55 * try fix netcdf4 install * h5py>=3.9.0 * monty>=2024.5.24 fixes TypeError: deprecated() got an unexpected keyword argument 'deadline' * revert TestWavecar to again inherit from PymatgenTest * h5py>=3.11.0 * phonopy>=2.23 * scipy>=1.13.0 * matplotlib>=3.8 * requests>=2.32 * don't run oldest/newest supported python twice on linux AND windows * fix bad refactor in get_atom_map fixes KeyError: 'Co' ipot = self.pot_dict[el.symbol]
1 parent 2982968 commit eccf075

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+179
-233
lines changed

.github/workflows/test.yml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,18 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28+
# maximize CI coverage of different platforms and python versions while minimizing the
29+
# total number of jobs. We run all pytest splits with the oldest supported python
30+
# version (currently 3.9) on windows (seems most likely to surface errors) and with
31+
# newest version (currently 3.12) on ubuntu (to get complete coverage on unix). We
32+
# ignore mac-os, which is assumed to be similar to ubuntu.
33+
config:
34+
- { os: windows-latest, python: "3.9", resolution: highest }
35+
- { os: ubuntu-latest, python: "3.12", resolution: lowest-direct }
2836
# pytest-split automatically distributes work load so parallel jobs finish in similar time
29-
os: [ubuntu-latest, windows-latest]
30-
python-version: ["3.9", "3.12"]
3137
split: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
32-
# include/exclude is meant to maximize CI coverage of different platforms and python
33-
# versions while minimizing the total number of jobs. We run all pytest splits with the
34-
# oldest supported python version (currently 3.9) on windows (seems most likely to surface
35-
# errors) and with newest version (currently 3.12) on ubuntu (to get complete and speedy
36-
# coverage on unix). We ignore mac-os, which is assumed to be similar to ubuntu.
37-
exclude:
38-
- os: windows-latest
39-
python-version: "3.12"
40-
- os: ubuntu-latest
41-
python-version: "3.9"
4238

43-
runs-on: ${{ matrix.os }}
39+
runs-on: ${{ matrix.config.os }}
4440

4541
env:
4642
PMG_MAPI_KEY: ${{ secrets.PMG_MAPI_KEY }}
@@ -55,13 +51,13 @@ jobs:
5551

5652
- name: Create mamba environment
5753
run: |
58-
micromamba create -n pmg python=${{ matrix.python-version }} --yes
54+
micromamba create -n pmg python=${{ matrix.config.python }} --yes
5955
6056
- name: Install uv
6157
run: micromamba run -n pmg pip install uv
6258

6359
- name: Install ubuntu-only conda dependencies
64-
if: matrix.os == 'ubuntu-latest'
60+
if: matrix.config.os == 'ubuntu-latest'
6561
run: |
6662
micromamba install -n pmg -c conda-forge enumlib packmol bader openbabel openff-toolkit --yes
6763
@@ -73,11 +69,7 @@ jobs:
7369
pip install torch
7470
7571
uv pip install numpy cython
76-
77-
uv pip install --editable '.[dev,optional]'
78-
79-
# TODO remove next line installing ase from main branch when FrechetCellFilter is released
80-
uv pip install --upgrade 'git+https://gitlab.com/ase/ase'
72+
uv pip install --editable '.[dev,optional]' --resolution=${{ matrix.config.resolution }}
8173
8274
- name: pytest split ${{ matrix.split }}
8375
run: |

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ci:
88

99
repos:
1010
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.4.3
11+
rev: v0.4.7
1212
hooks:
1313
- id: ruff
1414
args: [--fix, --unsafe-fixes]
@@ -27,7 +27,7 @@ repos:
2727
- id: mypy
2828

2929
- repo: https://github.com/codespell-project/codespell
30-
rev: v2.2.6
30+
rev: v2.3.0
3131
hooks:
3232
- id: codespell
3333
stages: [commit, commit-msg]
@@ -47,7 +47,7 @@ repos:
4747
- id: blacken-docs
4848

4949
- repo: https://github.com/igorshubovych/markdownlint-cli
50-
rev: v0.40.0
50+
rev: v0.41.0
5151
hooks:
5252
- id: markdownlint
5353
# MD013: line too long
@@ -64,6 +64,6 @@ repos:
6464
args: [--drop-empty-cells, --keep-output]
6565

6666
- repo: https://github.com/RobertCraigie/pyright-python
67-
rev: v1.1.361
67+
rev: v1.1.365
6868
hooks:
6969
- id: pyright

pymatgen/alchemy/materials.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def from_cif_str(
291291
TransformedStructure
292292
"""
293293
parser = CifParser.from_str(cif_string, occupancy_tolerance=occupancy_tolerance)
294-
raw_string = re.sub(r"'", '"', cif_string)
294+
raw_str = re.sub(r"'", '"', cif_string)
295295
cif_dict = parser.as_dict()
296296
cif_keys = list(cif_dict)
297297
struct = parser.parse_structures(primitive=primitive)[0]
@@ -303,7 +303,7 @@ def from_cif_str(
303303
source_info = {
304304
"source": source,
305305
"datetime": str(datetime.datetime.now()),
306-
"original_file": raw_string,
306+
"original_file": raw_str,
307307
"cif_data": cif_dict[cif_keys[0]],
308308
}
309309
return cls(struct, transformations, history=[source_info])
@@ -326,12 +326,12 @@ def from_poscar_str(
326326
raise ValueError(
327327
"Transformation can be created only from POSCAR strings with proper VASP5 element symbols."
328328
)
329-
raw_string = re.sub(r"'", '"', poscar_string)
329+
raw_str = re.sub(r"'", '"', poscar_string)
330330
struct = poscar.structure
331331
source_info = {
332332
"source": "POSCAR",
333333
"datetime": str(datetime.datetime.now()),
334-
"original_file": raw_string,
334+
"original_file": raw_str,
335335
}
336336
return cls(struct, transformations, history=[source_info])
337337

pymatgen/analysis/chemenv/connectivity/structure_connectivity.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ def setup_environment_subgraph(self, environments_symbols, only_atoms=None):
153153
if not isinstance(environments_symbols, collections.abc.Iterable):
154154
environments_symbols = [environments_symbols]
155155
environments_symbols = sorted(environments_symbols)
156-
envs_string = "-".join(environments_symbols)
156+
envs_str = "-".join(environments_symbols)
157157
if only_atoms is not None:
158-
envs_string += "#" + "-".join(sorted(only_atoms))
158+
envs_str += "#" + "-".join(sorted(only_atoms))
159159
# Get it directly if it was already computed
160-
if envs_string in self.environment_subgraphs:
161-
self._environment_subgraph = self.environment_subgraphs[envs_string]
160+
if envs_str in self.environment_subgraphs:
161+
self._environment_subgraph = self.environment_subgraphs[envs_str]
162162
return
163163

164164
# Initialize graph for a subset of environments
@@ -248,7 +248,7 @@ def setup_environment_subgraph(self, environments_symbols, only_atoms=None):
248248
delta=conn,
249249
ligands=ligands,
250250
)
251-
self.environment_subgraphs[envs_string] = self._environment_subgraph
251+
self.environment_subgraphs[envs_str] = self._environment_subgraph
252252

253253
def setup_connectivity_description(self):
254254
pass

pymatgen/analysis/elasticity/elastic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,8 @@ def get_compliance_expansion(self):
728728
if not self.order <= 4:
729729
raise ValueError("Compliance tensor expansion only supported for fourth-order and lower")
730730
ce_exp = [ElasticTensor(self[0]).compliance_tensor]
731-
ein_string = "ijpq,pqrsuv,rskl,uvmn->ijklmn"
732-
ce_exp.append(np.einsum(ein_string, -ce_exp[-1], self[1], ce_exp[-1], ce_exp[-1]))
731+
ein_str = "ijpq,pqrsuv,rskl,uvmn->ijklmn"
732+
ce_exp.append(np.einsum(ein_str, -ce_exp[-1], self[1], ce_exp[-1], ce_exp[-1]))
733733
if self.order == 4:
734734
# Four terms in the Fourth-Order compliance tensor
735735
einstring_1 = "pqab,cdij,efkl,ghmn,abcdefgh"

pymatgen/core/structure.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
from scipy.linalg import expm, polar
3737
from scipy.spatial.distance import squareform
3838
from tabulate import tabulate
39-
from typing_extensions import Self
4039

4140
from pymatgen.core.bonds import CovalentBond, get_bond_length
4241
from pymatgen.core.composition import Composition
@@ -60,6 +59,7 @@
6059
from ase.optimize.optimize import Optimizer
6160
from matgl.ext.ase import TrajectoryObserver
6261
from numpy.typing import ArrayLike, NDArray
62+
from typing_extensions import Self
6363

6464
from pymatgen.util.typing import CompositionLike, MillerIndex, PathLike, PbcLike, SpeciesLike
6565

@@ -3363,14 +3363,12 @@ def break_bond(self, ind1: int, ind2: int, tol: float = 0.2) -> tuple[Self, Self
33633363
Args:
33643364
ind1 (int): 1st site index
33653365
ind2 (int): 2nd site index
3366-
tol (float): Relative tolerance to test. Basically, the code
3367-
checks if the distance between the sites is less than (1 +
3368-
tol) * typical bond distances. Defaults to 0.2, i.e.,
3369-
20% longer.
3366+
tol (float): Relative tolerance to test. Basically, the code checks if the distance
3367+
between the sites is less than (1 + tol) * typical bond distances.
3368+
Defaults to 0.2, i.e. 20% longer.
33703369
33713370
Returns:
3372-
Two IMolecule representing the clusters formed from
3373-
breaking the bond.
3371+
tuple[IMolecule, IMolecule]: The clusters formed from breaking the bond.
33743372
"""
33753373
clusters = ([self[ind1]], [self[ind2]])
33763374

@@ -3393,7 +3391,8 @@ def belongs_to_cluster(site, cluster):
33933391
raise ValueError("Not all sites are matched!")
33943392
sites = unmatched
33953393

3396-
return cast(tuple[Self, Self], tuple(map(type(self).from_sites, clusters)))
3394+
from_sites = type(self).from_sites
3395+
return from_sites(clusters[0]), from_sites(clusters[1])
33973396

33983397
def get_covalent_bonds(self, tol: float = 0.2) -> list[CovalentBond]:
33993398
"""Determine the covalent bonds in a molecule.

pymatgen/io/abinit/inputs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,8 +1286,7 @@ def has_same_variable(kref, vref, other_inp):
12861286
return self[0].to_str(with_pseudos=with_pseudos)
12871287

12881288
def write(self, filepath="run.abi"):
1289-
"""
1290-
Write ndset input files to disk. The name of the file
1289+
"""Write ndset input files to disk. The name of the file
12911290
is constructed from the dataset index e.g. run0.abi.
12921291
"""
12931292
root, ext = os.path.splitext(filepath)

pymatgen/io/abinit/netcdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def __init__(self, path):
9292
self.ngroups = len(list(self.walk_tree()))
9393

9494
# Always return non-masked numpy arrays.
95-
# Slicing a ncvar returns a MaskedArrray and this is really annoying
95+
# Slicing a ncvar returns a MaskedArray and this is really annoying
9696
# because it can lead to unexpected behavior in e.g. calls to np.matmul!
9797
# See also https://github.com/Unidata/netcdf4-python/issues/785
9898
self.rootgrp.set_auto_mask(False)

pymatgen/io/adf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,7 @@ def __init__(self, task):
533533
self.task = task
534534

535535
def write_file(self, molecule, inp_file):
536-
"""
537-
Write an ADF input file.
536+
"""Write an ADF input file.
538537
539538
Args:
540539
molecule (Molecule): The molecule for this task.

pymatgen/io/common.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ def get_average_along_axis(self, ind):
266266
return total / ng[(ind + 1) % 3] / ng[(ind + 2) % 3]
267267

268268
def to_hdf5(self, filename):
269-
"""
270-
Writes the VolumetricData to a HDF5 format, which is a highly optimized
269+
"""Write the VolumetricData to a HDF5 format, which is a highly optimized
271270
format for reading storing large data. The mapping of the VolumetricData
272271
to this file format is as follows:
273272
@@ -323,8 +322,7 @@ def from_hdf5(cls, filename: str, **kwargs) -> Self:
323322
return cls(structure, data=data, data_aug=data_aug, **kwargs)
324323

325324
def to_cube(self, filename, comment: str = ""):
326-
"""
327-
Write the total volumetric data to a cube file format, which consists of two comment lines,
325+
"""Write the total volumetric data to a cube file format, which consists of two comment lines,
328326
a header section defining the structure IN BOHR, and the data.
329327
330328
Args:

0 commit comments

Comments
 (0)