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]
_extras := " --group " + (if which("nvidia-smi") == "" { "cpu" } else { f"cu{{CUDA_VERSION}}" }) + " "
[private]
_frozen := if env("FORCE_UV_NO_FREEZE", "") != "1" { " --frozen " } else { "" }
DEFAULT_UV_ARGS := "--dev --all-extras " + _extras + " " + _frozen

# Default: create the dev environment
default: dev

# Set up development environment
dev: sync-venv

# Format and lint code
[no-cd]
fmt:
    uv run {{ DEFAULT_UV_ARGS }} ruff format
    uv run {{ DEFAULT_UV_ARGS }} ruff check --output-format concise --fix --exit-non-zero-on-fix 

# Run type checkers
[no-cd]
ty-check:
    uv run {{ DEFAULT_UV_ARGS }} ty check --output-format concise

[no-cd]
pyrefly-check:
    uv run {{ DEFAULT_UV_ARGS }} pyrefly check --output-format min-text

[no-cd]
mypy-check:
    uv run {{ DEFAULT_UV_ARGS }} mypy --strict

# [parallel]
type-check: mypy-check

#pyrefly-check ty-check

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

# Run tests
[no-cd]
test:
    uv run {{ DEFAULT_UV_ARGS }} pytest --lf

# Sync virtual environment
sync-venv:
    uv sync {{ DEFAULT_UV_ARGS }}
