-
Notifications
You must be signed in to change notification settings - Fork 120
180 lines (173 loc) · 5.65 KB
/
Copy pathtest.yml
File metadata and controls
180 lines (173 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Test
on:
push:
branches: ["*"]
paths:
- "src/**"
- "tests/**"
- ".github/workflows/**"
- "pyproject.toml"
pull_request:
branches: [main]
paths:
- "src/**"
- "tests/**"
- ".github/workflows/**"
- "pyproject.toml"
release:
types: [published]
workflow_dispatch:
inputs:
task:
type: choice
options: [tests, release]
default: tests
description: Only run tests or release a new version to PyPI after tests pass.
jobs:
test:
strategy:
max-parallel: 20
matrix:
config:
- os: ubuntu-latest
python: "3.13"
optionals: "ops"
- os: ubuntu-latest
python: "3.13"
optionals: "alchmtk"
- os: ubuntu-latest
python: "3.13"
optionals: "jax"
- os: ubuntu-latest
python: "3.13"
- os: macos-latest
python: "3.11"
runs-on: ${{ matrix.config.os }}
env:
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: "python"
PMG_MAPI_KEY: ${{ secrets.PMG_MAPI_KEY }}
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: ${{ matrix.config.python }}
- name: Virtual env
run: uv venv --python ${{ matrix.config.python }} --clear
- name: Install dependencies
run: |
uv sync --upgrade
uv pip install -e ".[${{ matrix.config.optionals }}]"
uv pip install pytest pytest-cov
- name: pytest
run: |
uv run python -c "import torch; print(torch.__version__)"
uv run pytest --cov=matgl --cov-report=xml --cov-report=term tests --color=yes
- name: Upload coverage artifacts
if: matrix.config.optionals == 'ops'
uses: actions/upload-artifact@v5
with:
name: coverage
path: coverage.xml
if-no-files-found: error
test_grace_parity:
# Numerical parity job for the GRACE model against the upstream
# ``tensorpotential`` (TensorFlow) reference. Heavy install (TensorFlow
# ~500 MB) so it lives in a dedicated job rather than under the main
# test matrix. ``tensorpotential`` is intentionally NOT declared as a
# project dependency or extras group; we install it manually here.
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.11"]
env:
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: "python"
TF_CPP_MIN_LOG_LEVEL: "2"
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: ${{ matrix.python }}
- name: Virtual env
run: uv venv --python ${{ matrix.python }} --clear
- name: Install matgl
run: |
uv sync --upgrade
uv pip install -e .
uv pip install pytest
- name: Install tensorpotential (parity reference)
# Manual install — not added to pyproject.toml. We avoid pulling
# ``tensorpotential``'s full dependency closure for two reasons:
#
# 1. On Linux, ``tensorpotential`` pins ``tensorflow[and-cuda]<2.20``,
# whose ``nvidia-nccl-cu12`` extra clashes with torch's bundled
# NCCL ABI (``undefined symbol: ncclCommWindowDeregister``).
# 2. ``tensorpotential`` declares ``tf_keras`` as a dep, but the
# Linux/Python 3.11 wheel resolved here ships with
# ``saved_metadata.proto`` gencode 6.31.1 while ``tensorflow<2.20``
# constrains ``protobuf<6.0.0`` — TF 2.19 unconditionally imports
# ``tf_keras.src.optimizers`` at startup and the gencode/runtime
# check fails. The parity tests don't use Keras at all.
#
# We install ``tensorpotential`` itself with ``--no-deps`` and add
# only the runtime deps the parity test actually exercises.
run: |
uv pip install --no-deps "tensorpotential>=0.5.9"
uv pip install \
"tensorflow<2.20" \
"numpy<2" \
"scipy" \
"sympy" \
"matscipy" \
"pandas" \
"tqdm" \
"pyyaml"
- name: parity pytest
run: |
uv run python -c "import tensorflow as tf, tensorpotential; print('tf', tf.__version__)"
uv run pytest tests/models/test_grace_parity_tp.py tests/models/test_grace_training_parity.py -v --color=yes
coverage:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Download coverage
uses: actions/download-artifact@v5
with:
name: coverage
path: .
merge-multiple: true
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
files: coverage.xml
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
release:
if: github.event_name == 'release' || inputs.task == 'release'
needs: [test]
runs-on: ubuntu-latest
permissions:
# For pypi trusted publishing
id-token: write
steps:
- uses: actions/checkout@v5
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Build
run: |
pip install build
python -m build
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
verbose: true