# Set shell options for safety

set shell := ["bash", "-eu", "-o", "pipefail", "-c"]
set unstable

# If we want to use CUDA, the CUDA_VERSION variable should not be empty and contain the
# version number (either 12 or 13)

CUDA_VERSION := env("CUDA_VERSION", "12")
[private]
_env := if which("nvidia-smi") == "" { "default" } else { "cu" + CUDA_VERSION }
PIXI_ENV := env("PIXI_ENV", _env)
DEFAULT_PIXI_ARGS := "--environment " + PIXI_ENV

export PIXI_FROZEN := env("PIXI_FROZEN", "true")

# Default: create the dev environment
default: dev

# Set up development environment
dev: sync-venv

# Format and lint code
[no-cd]
fmt:
    ruff format
    ruff check --output-format concise --fix --exit-non-zero-on-fix .

# Run type checkers
[no-cd]
[private]
ty-check:
    ty check --output-format concise

[no-cd]
[private]
pyrefly-check:
    pyrefly check --output-format min-text

[no-cd]
[private]
mypy-check:
    mypy --strict

[no-cd]
[private]
pyright-check:
    basedpyright

# [parallel]
type-check: mypy-check

# pyright-check
# ty-check pyrefly-check

# Run both formatting and type checking
[no-cd]
lint: fmt type-check

# Run tests
[no-cd]
test:
    pytest --lf

docs:
    sphinx-build -b html docs/ docs/_build/html

# Sync virtual environment
sync-venv:
    pixi install {{ DEFAULT_PIXI_ARGS }}
