✨ Multi-dataset General ood eval #2013
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 | |
- dev | |
pull_request: | |
branches: | |
- dev | |
schedule: | |
- cron: "42 7 * * 0" | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10"] | |
env: | |
PYTHON_VERSION: ${{ matrix.python-version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "pip" | |
cache-dependency-path: "pyproject.toml" | |
# Update full Python version | |
- name: Full Python version | |
run: | | |
echo "PYTHON_VERSION=$(python -c "import platform; print(platform.python_version())")" | |
echo "PYTHON_VERSION=$(python -c "import platform; print(platform.python_version())")" >> $GITHUB_ENV | |
- name: Get changed files | |
id: changed-files-specific | |
uses: tj-actions/changed-files@v46 | |
with: | |
files: | | |
auto_tutorials_source/** | |
data/** | |
experiments/** | |
docs/** | |
*.md | |
*.yaml | |
*.yml | |
LICENSE | |
.gitignore | |
- name: Cache folder for TorchUncertainty | |
if: steps.changed-files-specific.outputs.only_changed != 'true' | |
uses: actions/cache@v4 | |
id: cache-folder | |
with: | |
path: | | |
~/.cache/torch-uncertainty/ | |
key: torch-uncertainty-${{ runner.os }} | |
- name: Install the minimal dependencies | |
if: steps.changed-files-specific.outputs.only_changed != 'true' | |
run: | | |
python3 -m pip install torch torchvision | |
python3 -m pip install . | |
- name: Check that torch-uncertainty can be imported | |
if: steps.changed-files-specific.outputs.only_changed != 'true' | |
run: | | |
python3 -c "import torch_uncertainty; from torch_uncertainty.datamodules import MNISTDataModule" | |
- name: Install the optional dependencies | |
if: steps.changed-files-specific.outputs.only_changed != 'true' | |
run: | | |
python3 -m pip install .[all] | |
- name: Check style & format | |
if: steps.changed-files-specific.outputs.only_changed != 'true' | |
run: | | |
python3 -m ruff check torch_uncertainty --no-fix --statistics | |
python3 -m ruff format torch_uncertainty --check | |
- name: Test with pytest and compute coverage | |
if: steps.changed-files-specific.outputs.only_changed != 'true' | |
run: | | |
python3 -m pytest tests --cov --cov-report xml --cov-report term --durations 10 --junitxml=junit.xml | |
- name: Upload coverage to Codecov | |
if: steps.changed-files-specific.outputs.only_changed != 'true' && (github.event_name != 'pull_request' || github.base_ref == 'dev') | |
uses: codecov/codecov-action@v4 | |
continue-on-error: true | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: coverage.xml | |
flags: pytest | |
name: CPU-coverage | |
env_vars: PYTHON_VERSION | |
- name: Upload test results to Codecov | |
if: steps.changed-files-specific.outputs.only_changed != 'true' && (github.event_name != 'pull_request' || github.base_ref == 'dev') | |
uses: codecov/test-results-action@v1 | |
continue-on-error: true | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
flags: pytest | |
env_vars: PYTHON_VERSION | |
- name: Test sphinx build without tutorials | |
if: steps.changed-files-specific.outputs.only_changed != 'true' | |
run: | | |
cd docs && make clean && make html-noplot |