Skip to content

Commit 8cb1729

Browse files
Merge remote-tracking branch 'upstream/master' into fstar
2 parents e9cea13 + 120da74 commit 8cb1729

Some content is hidden

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

60 files changed

+760
-474
lines changed

.github/workflows/release.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Runs the complete test suite incl. many external command line dependencies (like Openbabel)
2+
# as well as the pymatgen.ext package. Coverage is computed based on this workflow.
3+
name: Tests
4+
5+
on:
6+
release:
7+
types: [published]
8+
workflow_dispatch:
9+
inputs:
10+
task:
11+
type: choice
12+
options: [tests, release]
13+
default: tests
14+
description: Only run tests or release a new version of pymatgen to PyPI after tests pass.
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
test:
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os: [ubuntu-latest]
25+
python-version: ["3.11"]
26+
27+
runs-on: ${{ matrix.os }}
28+
29+
env:
30+
PMG_MAPI_KEY: ${{ secrets.PMG_MAPI_KEY }}
31+
MPLBACKEND: Agg # https://github.com/orgs/community/discussions/26434
32+
PMG_TEST_FILES_DIR: ${{ github.workspace }}/tests/files
33+
GULP_LIB: ${{ github.workspace }}/cmd_line/gulp/Libraries
34+
PMG_VASP_PSP_DIR: ${{ github.workspace }}/tests/files
35+
36+
steps:
37+
- uses: actions/checkout@v3
38+
- name: Set up Python ${{ matrix.python-version }}
39+
uses: actions/setup-python@v4
40+
with:
41+
python-version: ${{ matrix.python-version }}
42+
cache: pip
43+
cache-dependency-path: setup.py
44+
- name: Copy GULP to bin
45+
if: matrix.os == 'ubuntu-latest'
46+
run: |
47+
sudo cp cmd_line/gulp/Linux_64bit/* /usr/local/bin/
48+
- name: Install Bader
49+
if: matrix.os == 'ubuntu-latest'
50+
run: |
51+
wget http://theory.cm.utexas.edu/henkelman/code/bader/download/bader_lnx_64.tar.gz
52+
tar xvzf bader_lnx_64.tar.gz
53+
sudo mv bader /usr/local/bin/
54+
continue-on-error: true # This is not critical to succeed.
55+
- name: Install Enumlib
56+
if: matrix.os == 'ubuntu-latest'
57+
run: |
58+
git clone --recursive https://github.com/msg-byu/enumlib.git
59+
cd enumlib/symlib/src
60+
export F90=gfortran
61+
make
62+
cd ../../src
63+
make enum.x
64+
sudo mv enum.x /usr/local/bin/
65+
cd ..
66+
sudo cp aux_src/makeStr.py /usr/local/bin/
67+
continue-on-error: true # This is not critical to succeed.
68+
- name: Install dependencies
69+
run: |
70+
python -m pip install --upgrade pip wheel
71+
python -m pip install numpy cython packaging
72+
python -m pip install -e '.[dev,optional]'
73+
- name: pytest
74+
run: |
75+
pytest --cov=pymatgen tests
76+
- name: Upload coverage reports to Codecov
77+
uses: codecov/codecov-action@v3
78+
with:
79+
token: ${{ secrets.CODECOV_TOKEN }}
80+
verbose: true
81+
82+
build_sdist:
83+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release')
84+
needs: test
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@v3
88+
- uses: actions/setup-python@v4
89+
name: Install Python
90+
with:
91+
python-version: "3.10"
92+
- run: |
93+
python -m pip install build
94+
pip install -e .
95+
- name: Build sdist
96+
run: python -m build --sdist
97+
- uses: actions/upload-artifact@v3
98+
with:
99+
path: dist/*.tar.gz
100+
101+
build_wheels:
102+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release')
103+
needs: test
104+
strategy:
105+
matrix:
106+
os: [ubuntu-latest, macos-latest, windows-latest]
107+
python-version: ["39", "310", "311"]
108+
runs-on: ${{ matrix.os }}
109+
steps:
110+
- uses: actions/checkout@v3
111+
- name: Build wheels
112+
uses: pypa/[email protected]
113+
env:
114+
CIBW_BUILD: cp${{ matrix.python-version }}-*
115+
- name: Save artifact
116+
uses: actions/upload-artifact@v3
117+
with:
118+
path: ./wheelhouse/*.whl
119+
120+
release:
121+
needs: [build_wheels, build_sdist]
122+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release')
123+
runs-on: ubuntu-latest
124+
permissions:
125+
# For pypi trusted publishing
126+
id-token: write
127+
steps:
128+
- name: Set up Python 3.11
129+
uses: actions/setup-python@v4
130+
with:
131+
python-version: 3.11
132+
- name: Get build artifacts
133+
uses: actions/download-artifact@v3
134+
with:
135+
name: artifact
136+
path: dist
137+
- name: Publish to PyPi
138+
uses: pypa/gh-action-pypi-publish@release/v1
139+
with:
140+
skip-existing: true
141+
verbose: true

.github/workflows/test.yml

Lines changed: 12 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ on:
99
pull_request:
1010
branches: [master]
1111
paths-ignore: ["**/*.md", docs/**]
12-
release:
13-
types: [published]
1412
workflow_dispatch:
1513
inputs:
1614
task:
@@ -22,10 +20,6 @@ on:
2220
permissions:
2321
contents: read
2422

25-
concurrency:
26-
group: ${{ github.workflow }}-${{ github.ref }}
27-
cancel-in-progress: true
28-
2923
jobs:
3024
test:
3125
# prevent this action from running on forks
@@ -35,31 +29,18 @@ jobs:
3529
matrix:
3630
# pytest-split automatically distributes work load so parallel jobs finish in similar time
3731
os: [ubuntu-latest, windows-latest]
38-
python-version: ["3.8", "3.11"]
32+
python-version: ["3.9", "3.11"]
3933
split: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
4034
# include/exclude is meant to maximize CI coverage of different platforms and python
4135
# versions while minimizing the total number of jobs. We run all pytest splits with the
42-
# oldest supported python version (currently 3.8) on windows (seems most likely to surface
36+
# oldest supported python version (currently 3.9) on windows (seems most likely to surface
4337
# errors) and with newest version (currently 3.11) on ubuntu (to get complete and speedy
44-
# coverage on unix). Also sample some splits on macos for all python versions
38+
# coverage on unix). We ignore mac-os, which is assumed to be similar to ubuntu.
4539
exclude:
4640
- os: windows-latest
4741
python-version: "3.11"
4842
- os: ubuntu-latest
49-
python-version: "3.8"
50-
include:
51-
- os: macos-latest
52-
python-version: "3.8"
53-
split: 1
54-
- os: macos-latest
5543
python-version: "3.9"
56-
split: 2
57-
- os: macos-latest
58-
python-version: "3.10"
59-
split: 3
60-
- os: macos-latest
61-
python-version: "3.11"
62-
split: 4
6344

6445
runs-on: ${{ matrix.os }}
6546

@@ -78,20 +59,19 @@ jobs:
7859
python-version: ${{ matrix.python-version }}
7960
cache: pip
8061
cache-dependency-path: setup.py
81-
- name: Copy CLIs to bin
82-
if: runner.os == 'Linux'
83-
# This is the way to update env variables in a way that persist for the entire job.
62+
- name: Copy GULP to bin
63+
if: matrix.os == 'ubuntu-latest'
8464
run: |
8565
sudo cp cmd_line/gulp/Linux_64bit/* /usr/local/bin/
8666
- name: Install Bader
87-
if: runner.os == 'Linux'
67+
if: matrix.os == 'ubuntu-latest'
8868
run: |
8969
wget http://theory.cm.utexas.edu/henkelman/code/bader/download/bader_lnx_64.tar.gz
9070
tar xvzf bader_lnx_64.tar.gz
9171
sudo mv bader /usr/local/bin/
92-
continue-on-error: true
72+
continue-on-error: true # This is not critical to succeed.
9373
- name: Install Enumlib
94-
if: runner.os == 'Linux'
74+
if: matrix.os == 'ubuntu-latest'
9575
run: |
9676
git clone --recursive https://github.com/msg-byu/enumlib.git
9777
cd enumlib/symlib/src
@@ -102,9 +82,9 @@ jobs:
10282
sudo mv enum.x /usr/local/bin/
10383
cd ..
10484
sudo cp aux_src/makeStr.py /usr/local/bin/
105-
continue-on-error: true
85+
continue-on-error: true # This is not critical to succeed.
10686
- name: Install Packmol
107-
if: runner.os == 'Linux'
87+
if: matrix.os == 'ubuntu-latest'
10888
run: |
10989
wget -O packmol.tar.gz https://github.com/m3g/packmol/archive/refs/tags/v20.14.2.tar.gz
11090
tar xvzf packmol.tar.gz
@@ -114,102 +94,12 @@ jobs:
11494
make
11595
sudo mv packmol /usr/local/bin/
11696
cd ..
117-
rm -rf .coverage*
118-
continue-on-error: true
97+
continue-on-error: true # This is not critical to succeed.
11998
- name: Install dependencies
12099
run: |
121100
python -m pip install --upgrade pip wheel
122101
python -m pip install numpy cython packaging
123102
python -m pip install -e '.[dev,optional]'
124103
- name: pytest split ${{ matrix.split }}
125104
run: |
126-
pytest --cov=pymatgen --splits 10 --group ${{ matrix.split }} --durations-path tests/files/.pytest-split-durations tests
127-
- name: Upload coverage
128-
# Only upload coverage for ubuntu py3.11 runs. Continue on error as coverage is not critical.
129-
if: github.event_name != 'pull_request' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
130-
uses: actions/upload-artifact@v3
131-
with:
132-
name: coverage-${{ matrix.split }}
133-
path: .coverage
134-
135-
coverage:
136-
# Only upload coverage for ubuntu py3.11 runs. Continue on error as coverage is not critical.
137-
if: github.event_name != 'pull_request'
138-
needs: test
139-
runs-on: ubuntu-latest
140-
steps:
141-
- uses: actions/checkout@v3
142-
- name: Download coverage artifacts
143-
uses: actions/download-artifact@v3
144-
- name: Combine coverage
145-
run: |
146-
pip install coverage[toml]
147-
find . -name "*.pyc" -delete
148-
for i in {1..10}; do mv coverage-$i/.coverage .coverage.$i; rm -rf coverage-$i; done
149-
coverage combine
150-
- name: Upload coverage reports to Codecov
151-
uses: codecov/codecov-action@v3
152-
with:
153-
token: ${{ secrets.CODECOV_TOKEN }}
154-
verbose: true
155-
156-
build_sdist:
157-
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release')
158-
needs: test
159-
runs-on: ubuntu-latest
160-
steps:
161-
- uses: actions/checkout@v3
162-
- uses: actions/setup-python@v4
163-
name: Install Python
164-
with:
165-
python-version: "3.10"
166-
- run: |
167-
python -m pip install build
168-
pip install -e .
169-
- name: Build sdist
170-
run: python -m build --sdist
171-
- uses: actions/upload-artifact@v3
172-
with:
173-
path: dist/*.tar.gz
174-
175-
build_wheels:
176-
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release')
177-
needs: test
178-
strategy:
179-
matrix:
180-
os: [ubuntu-latest, macos-latest, windows-latest]
181-
python-version: ["38", "39", "310", "311"]
182-
runs-on: ${{ matrix.os }}
183-
steps:
184-
- uses: actions/checkout@v3
185-
- name: Build wheels
186-
uses: pypa/[email protected]
187-
env:
188-
CIBW_BUILD: cp${{ matrix.python-version }}-*
189-
- name: Save artifact
190-
uses: actions/upload-artifact@v3
191-
with:
192-
path: ./wheelhouse/*.whl
193-
194-
release:
195-
needs: [build_wheels, build_sdist]
196-
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release')
197-
runs-on: ubuntu-latest
198-
permissions:
199-
# For pypi trusted publishing
200-
id-token: write
201-
steps:
202-
- name: Set up Python 3.11
203-
uses: actions/setup-python@v4
204-
with:
205-
python-version: 3.11
206-
- name: Get build artifacts
207-
uses: actions/download-artifact@v3
208-
with:
209-
name: artifact
210-
path: dist
211-
- name: Publish to PyPi
212-
uses: pypa/gh-action-pypi-publish@release/v1
213-
with:
214-
skip-existing: true
215-
verbose: true
105+
pytest --splits 10 --group ${{ matrix.split }} --durations-path tests/files/.pytest-split-durations tests

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ For developers interested in expanding `pymatgen` for their own purposes, we rec
6868

6969
Given that `pymatgen` is intended to be a long-term code base, we adopt very strict quality control and coding guidelines for all contributions to `pymatgen`. The following must be satisfied for your contributions to be accepted into `pymatgen`.
7070

71-
1. **Unit tests** are required for all new modules and methods. The only way to minimize code regression is to ensure that all code is well tested. Untested contributions will not be accepted.
71+
1. **Unit tests** are required for all new modules and methods. The only way to minimize code regression is to ensure that all code is well-tested. Untested contributions will not be accepted.
7272
1. **Python PEP 8** [code style](https://python.org/dev/peps/pep-0008). We allow a few exceptions when they are well-justified (e.g., Element's atomic number is given a variable name of capital Z, in line with accepted scientific convention), but generally, PEP 8 must be observed. Code style will be automatically checked for all PRs and must pass before any PR is merged. To aid you, you can install and run the same set of formatters and linters that will run in CI using
7373
7474
```sh
@@ -78,7 +78,7 @@ Given that `pymatgen` is intended to be a long-term code base, we adopt very str
7878
pre-commit run --all-files # ensure your entire codebase passes linters
7979
```
8080
81-
1. **Python 3**. We only support Python 3.8+.
81+
1. **Python 3**. We only support Python 3.9+.
8282
1. **Documentation** is required for all modules, classes and methods. In particular, the method doc strings should make clear the arguments expected and the return values. For complex algorithms (e.g., an Ewald summation), a summary of the algorithm should be provided and preferably with a link to a publication outlining the method in detail.
8383
8484
For the above, if in doubt, please refer to the core classes in `pymatgen` for examples of what is expected.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ If you'd like to use the latest unreleased changes on the main branch, you can i
6464
pip install -U git+https://github.com/materialsproject/pymatgen
6565
```
6666

67-
The minimum Python version is 3.8. Some extra functionality (e.g., generation of POTCARs) does require additional setup (see the [`pymatgen` docs]).
67+
The minimum Python version is 3.9. Some extra functionality (e.g., generation of POTCARs) does require additional setup (see the [`pymatgen` docs]).
6868

6969
## Change Log
7070

dev_scripts/chemenv/strategies/multi_weights_strategy_parameters.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import copy
66
import json
7-
from typing import Sequence
7+
from typing import TYPE_CHECKING
88

99
import matplotlib.pyplot as plt
1010
import numpy as np
@@ -26,6 +26,9 @@
2626
from pymatgen.core.lattice import Lattice
2727
from pymatgen.core.structure import Structure
2828

29+
if TYPE_CHECKING:
30+
from collections.abc import Sequence
31+
2932
__author__ = "David Waroquiers"
3033
__copyright__ = "Copyright 2012, The Materials Project"
3134
__version__ = "2.0"

0 commit comments

Comments
 (0)