File size: 1,126 Bytes
19fc84f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
# Run pytest inside the Singularity container.
# All arguments are forwarded to pytest as-is.
#
# Prerequisites: .env must define SIF_DIR (and optionally DATA_ROOT, HF_HOME).
# See docs/context/04_environment_setup.md and .env.example.
#
# Usage:
#   bash scripts/run_tests.sh                          # run all tests
#   bash scripts/run_tests.sh tests/test_calibration.py -v
set -euo pipefail

REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
source "${REPO_ROOT}/.env"

if [[ -z "${SIF_DIR:-}" ]]; then
    echo "ERROR: SIF_DIR is not set. Fill in .env (see .env.example)." >&2
    exit 1
fi

# Build the bind list only for paths that are set.
BINDS=()
if [[ -n "${DATA_ROOT:-}" ]]; then
    BINDS+=(--bind "${DATA_ROOT}/data:${REPO_ROOT}/data")
    BINDS+=(--bind "${DATA_ROOT}/index_store:${REPO_ROOT}/index_store")
fi
if [[ -n "${HF_HOME:-}" ]]; then
    BINDS+=(--bind "${HF_HOME}:${HF_HOME}")
fi

singularity exec \
    "${BINDS[@]}" \
    --env HF_HOME="${HF_HOME:-}" \
    --env DATA_ROOT="${REPO_ROOT}" \
    --pwd "${REPO_ROOT}" \
    "${SIF_DIR}/response_quality.sif" \
    python -m pytest "$@"