Skip to content

fix: add Torch include directories and fix type mismatch #6

fix: add Torch include directories and fix type mismatch

fix: add Torch include directories and fix type mismatch #6

Workflow file for this run

name: Build and Test
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
jobs:
# Build CPU-only version for multiple platforms
build-cpu:
name: Build CPU (${{ matrix.os }}, Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-20.04, macos-12, macos-14, windows-2022]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
exclude:
# macOS 14 (Apple Silicon) doesn't support Python 3.8 and 3.9
- os: macos-14
python-version: "3.8"
- os: macos-14
python-version: "3.9"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install cmake
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install build wheel setuptools>=64
pip install torch>=2.0.0 numpy>=1.20.0
pip install pytest pytest-cov
- name: Build package
run: |
python -m build --wheel
env:
AMMS_ENABLE_CUDA: "0"
- name: Install package
run: |
pip install dist/*.whl
- name: Run tests
run: |
pytest tests/ -v --cov=sage.libs.amms --cov-report=xml
- name: Upload coverage
if: matrix.os == 'ubuntu-22.04' && matrix.python-version == '3.11'
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}-py${{ matrix.python-version }}
path: dist/*.whl
# Build CUDA version (Linux only)
build-cuda:
name: Build CUDA (Ubuntu, Python ${{ matrix.python-version }}, CUDA ${{ matrix.cuda-version }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
cuda-version: ["11.8", "12.1"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install CUDA Toolkit
uses: Jimver/cuda-toolkit@v0.2.14
with:
cuda: ${{ matrix.cuda-version }}
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install build wheel setuptools>=64
pip install torch>=2.0.0 numpy>=1.20.0
pip install pytest pytest-cov
- name: Build package with CUDA
run: |
python -m build --wheel
env:
AMMS_ENABLE_CUDA: "1"
CUDA_HOME: /usr/local/cuda
- name: Install package
run: |
pip install dist/*.whl
- name: Run tests
run: |
pytest tests/ -v -k "not cuda" || true # CUDA tests may fail without GPU
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-cuda${{ matrix.cuda-version }}-py${{ matrix.python-version }}
path: dist/*.whl
# Code quality checks
lint:
name: Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black ruff mypy numpy torch
- name: Check formatting with Black
run: |
black --check sage/ tests/
- name: Lint with Ruff
run: |
ruff check sage/ tests/
- name: Type check with mypy
run: |
mypy sage/libs/amms/interface/ --ignore-missing-imports