Neighborlist api to handle batch #1665
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 }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test-core: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-14] | |
| version: | |
| - { python: '3.12', resolution: highest } | |
| - { python: '3.12', resolution: lowest-direct } | |
| - { python: '3.13', resolution: highest } | |
| - { python: '3.13', 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 | |
| # always use numpy>=2 with Python 3.13 | |
| if [ "${{ matrix.version.python }}" = "3.13" ]; then | |
| uv pip install -e ".[test]" "numpy>=2" --resolution=${{ matrix.version.resolution }} --system | |
| else | |
| uv pip install -e ".[test]" --resolution=${{ matrix.version.resolution }} --system | |
| fi | |
| - name: Run core tests | |
| run: | | |
| pytest --cov=torch_sim --cov-report=xml | |
| - 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.12', resolution: highest } | |
| - { python: '3.12', resolution: lowest-direct } | |
| - { python: '3.13', resolution: highest } | |
| - { python: '3.13', resolution: lowest-direct } | |
| model: | |
| - { name: fairchem, test_path: "tests/models/test_fairchem.py" } | |
| - { name: fairchem-legacy, test_path: "tests/models/test_fairchem_legacy.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: nequip, test_path: "tests/models/test_nequip_framework.py" } | |
| - { name: orb, test_path: "tests/models/test_orb.py" } | |
| - { name: sevenn, test_path: "tests/models/test_sevennet.py" } | |
| exclude: | |
| - version: { python: '3.13', resolution: lowest-direct } | |
| model: { name: orb, test_path: "tests/models/test_orb.py" } | |
| - version: { python: '3.13', resolution: highest } | |
| model: { name: orb, test_path: "tests/models/test_orb.py" } | |
| - version: { python: '3.13', resolution: lowest-direct } | |
| model: { name: fairchem-legacy, test_path: "tests/models/test_fairchem_legacy.py" } | |
| - version: { python: '3.13', resolution: highest } | |
| model: { name: fairchem-legacy, test_path: "tests/models/test_fairchem_legacy.py" } | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@v4 | |
| - name: Check out fairchem repository | |
| if: ${{ matrix.model.name == 'fairchem-legacy' }} | |
| 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 HDF5 on macOS | |
| if: runner.os == 'macOS' | |
| run: brew install hdf5 | |
| - name: Install legacy fairchem repository and dependencies | |
| if: ${{ matrix.model.name == 'fairchem-legacy' }} | |
| run: | | |
| 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-legacy' }} | |
| run: | | |
| # always use numpy>=2 with Python 3.13 | |
| if [ "${{ matrix.version.python }}" = "3.13" ]; then | |
| uv pip install -e ".[test,${{ matrix.model.name }}]" "numpy>=2" --resolution=${{ matrix.version.resolution }} --system | |
| else | |
| uv pip install -e ".[test,${{ matrix.model.name }}]" --resolution=${{ matrix.version.resolution }} --system | |
| fi | |
| - name: Run ${{ matrix.model.test_path }} tests | |
| if: ${{ !contains(matrix.model.name, 'fairchem') || github.event.pull_request.head.repo.fork == false }} | |
| env: | |
| HF_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }} | |
| run: | | |
| if [[ "${{ matrix.model.name }}" == *"fairchem"* ]]; then | |
| uv pip install "huggingface_hub[cli]" --system | |
| hf auth login --token "$HF_TOKEN" | |
| fi | |
| pytest -vv -ra -rs --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.12' | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Run example | |
| if: ${{ !contains(matrix.example, 'fairchem') || github.event.pull_request.head.repo.fork == false }} | |
| env: | |
| HF_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }} | |
| run: | | |
| if [[ "${{ matrix.example }}" == *"fairchem"* ]]; then | |
| uv pip install "huggingface_hub[cli]" --system | |
| hf auth login --token "$HF_TOKEN" | |
| fi | |
| uv run --with . ${{ matrix.example }} |