Fairchem v2 support #1188
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
workflow_dispatch: | |
workflow_call: | |
concurrency: | |
group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }} | |
cancel-in-progress: true | |
jobs: | |
test-core: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-14] | |
version: | |
- { python: "3.11", resolution: highest } | |
- { python: "3.12", resolution: lowest-direct } | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.version.python }} | |
- name: Set up uv | |
uses: astral-sh/setup-uv@v6 | |
- name: Install torch_sim | |
run: | | |
uv pip install "torch>2" --index-url https://download.pytorch.org/whl/cpu --system | |
uv pip install -e .[test] --resolution=${{ matrix.version.resolution }} --system | |
- name: Run core tests | |
run: | | |
pytest --cov=torch_sim --cov-report=xml \ | |
--ignore=tests/test_elastic.py \ | |
--ignore=tests/models/test_fairchem.py \ | |
--ignore=tests/models/test_graphpes.py \ | |
--ignore=tests/models/test_mace.py \ | |
--ignore=tests/models/test_orb.py \ | |
--ignore=tests/models/test_sevennet.py \ | |
--ignore=tests/models/test_mattersim.py \ | |
--ignore=tests/models/test_metatomic.py \ | |
--ignore=tests/test_optimizers_vs_ase.py \ | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
slug: radical-ai/torch-sim | |
test-model: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-14] | |
version: | |
- { python: "3.11", resolution: highest } | |
- { python: "3.12", resolution: lowest-direct } | |
model: | |
- { name: fairchem, test_path: "tests/models/test_fairchem.py" } | |
- { name: graphpes, test_path: "tests/models/test_graphpes.py" } | |
- { name: mace, test_path: "tests/models/test_mace.py" } | |
- { name: mace, test_path: "tests/test_elastic.py" } | |
- { name: mace, test_path: "tests/test_optimizers_vs_ase.py" } | |
- { name: mattersim, test_path: "tests/models/test_mattersim.py" } | |
- { name: metatomic, test_path: "tests/models/test_metatomic.py" } | |
- { name: orb, test_path: "tests/models/test_orb.py" } | |
- { name: sevenn, test_path: "tests/models/test_sevennet.py" } | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.version.python }} | |
- name: Set up uv | |
uses: astral-sh/setup-uv@v6 | |
- name: Install fairchem and dependencies | |
if: ${{ matrix.model.name == 'fairchem' }} | |
env: | |
HF_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }} | |
run: | | |
uv pip install "torch>=2.6" --index-url https://download.pytorch.org/whl/cpu --system | |
uv pip install "fairchem-core>=2.2.0" --system | |
uv pip install "huggingface_hub[cli]" --system | |
uv pip install -e .[test] --resolution=${{ matrix.version.resolution }} --system | |
- name: Install torch_sim with model dependencies | |
if: ${{ matrix.model.name != 'fairchem' }} | |
run: | | |
uv pip install -e .[test,${{ matrix.model.name }}] --resolution=${{ matrix.version.resolution }} --system | |
- name: Run ${{ matrix.model.test_path }} tests | |
env: | |
HF_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }} | |
run: | | |
if [ "${{ matrix.model.name }}" == "fairchem" ]; then | |
huggingface-cli login --token "$HF_TOKEN" | |
fi | |
pytest --cov=torch_sim --cov-report=xml ${{ matrix.model.test_path }} | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
slug: radical-ai/torch-sim | |
find-examples: | |
runs-on: ubuntu-latest | |
outputs: | |
examples: ${{ steps.set-matrix.outputs.examples }} | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Find example scripts | |
id: set-matrix | |
run: | | |
# Find all example scripts but exclude known failing ones | |
EXAMPLES=$(find examples -name "*.py" | jq -R -s -c 'split("\n")[:-1]') | |
echo "examples=$EXAMPLES" >> $GITHUB_OUTPUT | |
test-examples: | |
needs: find-examples | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
example: ${{fromJson(needs.find-examples.outputs.examples)}} | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Set up uv | |
uses: astral-sh/setup-uv@v6 | |
- name: Run example | |
env: | |
HF_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }} | |
run: | | |
if [[ "${{ matrix.example }}" == *"fairchem"* ]]; then | |
uv pip install "huggingface_hub[cli]" --system | |
huggingface-cli login --token "$HF_TOKEN" | |
fi | |
uv run --with . ${{ matrix.example }} |