Skip to content

Update readme plot (#236) #1175

Update readme plot (#236)

Update readme plot (#236) #1175

Workflow file for this run

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: Check out fairchem repository
if: ${{ matrix.model.name == 'fairchem' }}
uses: actions/checkout@v4
with:
repository: FAIR-Chem/fairchem
path: fairchem-repo
ref: fairchem_core-1.10.0
- 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 repository and dependencies
if: ${{ matrix.model.name == 'fairchem' }}
env:
HF_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
run: |
uv pip install huggingface_hub --system
if [ -n "$HF_TOKEN" ]; then
huggingface-cli login --token "$HF_TOKEN"
else
echo "HF_TOKEN is not set. Skipping login."
fi
if [ -f fairchem-repo/packages/requirements.txt ]; then
uv pip install -r fairchem-repo/packages/requirements.txt --system
fi
if [ -f fairchem-repo/packages/requirements-optional.txt ]; then
uv pip install -r fairchem-repo/packages/requirements-optional.txt --system
fi
uv pip install -e fairchem-repo/packages/fairchem-core[dev] --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
run: |
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
run: uv run --with . ${{ matrix.example }}