Files
party2d/run_estimation.sh
T
2026-06-15 11:33:18 +02:00

57 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
MODE="${1:-reuse}"
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
cd "$repo_root"
case "$MODE" in
full|reuse|dry-run) ;;
*)
echo "Usage: $0 [full|reuse|dry-run]" >&2
exit 1
;;
esac
export PARTY2D_RAW_DATA_DIR="${PARTY2D_RAW_DATA_DIR:-$repo_root/_local/raw}"
export TMPDIR="${TMPDIR:-$repo_root/_local/tmp}"
mkdir -p "$TMPDIR"
if [ "$MODE" = "dry-run" ]; then
echo "Checking commands..."
command -v bash >/dev/null
command -v Rscript >/dev/null
command -v julia >/dev/null
echo "Checking key files..."
test -f Project.toml
test -f Manifest.toml
test -f models/stan_model_2dim_v6.stan
test -f data/text_data.csv
test -f data/expert.csv
test -f data/lr_data.csv
test -f data/model_data.csv
echo "Checking shell syntax..."
bash -n scripts/01_prepare_data.sh
bash -n scripts/02_fit_model.sh
bash -n scripts/03_extract_estimates.sh
bash -n scripts/04_enrich_estimates.sh
bash -n scripts/05_validate_estimates.sh
echo "Checking R syntax..."
Rscript -e 'files <- list.files("src/r", pattern="\\.R$", full.names=TRUE); invisible(lapply(files, parse))'
echo "Checking Julia project can instantiate without running model code..."
julia --project=. -e 'import Pkg; Pkg.instantiate(); println("Julia project OK")'
echo "Dry run passed. No model fitting was run."
exit 0
fi
bash scripts/01_prepare_data.sh
if [ "$MODE" = "full" ]; then
bash scripts/02_fit_model.sh
else
echo "reuse: skipping Stan model fitting; using latest existing model output"
fi
bash scripts/03_extract_estimates.sh
bash scripts/04_enrich_estimates.sh