set dotenv-load

data_dir := "data"
entities_db := "artifacts/entities.db"
entities_xlsx := "data/2026-04-29-entities.xlsx"
ito_xlsx := "data/2026-04-29-ito-list.xlsx"
geo_csv := "data/2025-12-20-geo-k12-deped.csv"
r2_prefix := "deped-entity"

# serve documentation
docs:
    uv run zensical serve --dev-addr localhost:8002

# create .env file from example
dumpenv:
    op inject -i env.example -o .env

# upload to pypi
publish:
    uv build && \
    UV_PUBLISH_TOKEN=$PYPI_TOKEN uv publish

# download data from r2
download:
    uv run deped-dcp-template r2 download --target {{ data_dir }} --prefix {{ r2_prefix }}

# upload data to r2
upload:
    uv run deped-dcp-template r2 upload --source {{ data_dir }} --prefix {{ r2_prefix }}

# build entities database
build:
    uv run entity build \
    --input {{ entities_xlsx }} \
    --ito-input {{ ito_xlsx }} \
    --geo-input {{ geo_csv }} \
    --db {{ entities_db }}

# audit entities database
audit:
    uv run entity audit \
    --db {{ entities_db }}

# run entity pipeline from scratch
restart:
    rm -rf artifacts && \
    mkdir -p artifacts && \
    just build
