11#! /bin/sh
22set -e
33
4- # Auto-detect mode if EXECUTION_MODE=auto
4+ INPUT_DIR=" data/inputs"
5+ OUTPUT_DIR=" data/outputs"
6+
7+ # --------------------------
8+ # DEBUG ENVIRONMENT VARIABLES
9+ # --------------------------
10+ echo " === DEBUG: Environment Variables ==="
11+ echo " ADEQUACY: '$ADEQUACY '"
12+ echo " BOOTSTRAP_SIZE: '$BOOTSTRAP_SIZE '"
13+ echo " EXECUTION_MODE: '$EXECUTION_MODE '"
14+ echo " VERBOSE: '$VERBOSE '"
15+ echo " ===================================="
16+
17+ # --------------------------
18+ # Discover the DAGs first (.dot)
19+ # --------------------------
20+ DAG_FILES=$( find " $INPUT_DIR /dag-data" -name " *.dot" 2> /dev/null || true)
21+
22+ if [ -z " $DAG_FILES " ]; then
23+ echo " ERROR: No .dot DAG file found in $INPUT_DIR /dag-data"
24+ exit 1
25+ fi
26+
27+ set -- $DAG_FILES
28+ if [ " $# " -ne 1 ]; then
29+ echo " ERROR: Expected exactly one DAG (.dot) file, found $# "
30+ exit 1
31+ fi
32+
33+ DAG_PATH=" $1 "
34+ echo " Using DAG file: $DAG_PATH "
35+
36+ # --------------------------
37+ # Discover runtime CSV data (can be multiple)
38+ # --------------------------
39+ DATA_PATHS=$( find " $INPUT_DIR /runtime-data" -name " *.csv" 2> /dev/null || true)
40+
41+ if [ -z " $DATA_PATHS " ]; then
42+ echo " ERROR: No runtime CSV files found in $INPUT_DIR /runtime-data"
43+ exit 1
44+ fi
45+
46+ echo " Found CSV files: $DATA_PATHS "
47+
48+ # Causal tests path for checking if it exists in inputs
49+ CAUSAL_TESTS_INPUT_PATH=" $INPUT_DIR /causal-tests/$CAUSAL_TESTS "
50+ # Causal tests path for writing (generate mode)
51+ CAUSAL_TESTS_OUTPUT_PATH=" $OUTPUT_DIR /$CAUSAL_TESTS "
52+ # Results path (test mode)
53+ CAUSAL_TEST_RESULTS_PATH=" $OUTPUT_DIR /$CAUSAL_TEST_RESULTS "
54+
55+ # --------------------------
56+ # Auto-detect mode
57+ # --------------------------
558if [ " $EXECUTION_MODE " = " auto" ]; then
6- if [ -f " $CAUSAL_TESTS " ]; then
59+ if [ -d " $INPUT_DIR /causal-tests " ] && [ - f " $CAUSAL_TESTS_INPUT_PATH " ]; then
760 EXECUTION_MODE=" test"
8- echo " Auto mode: causal_tests.json found -> running TEST mode"
61+ echo " Auto mode: causal tests found in inputs -> running TEST mode"
962 else
1063 EXECUTION_MODE=" generate"
11- echo " Auto mode: No causal tests found -> running GENERATE mode"
64+ echo " Auto mode: no causal tests found in inputs -> running GENERATE mode"
1265 fi
1366else
1467 echo " Execution mode explicitly set to: $EXECUTION_MODE "
1972# --------------------------
2073if [ " $EXECUTION_MODE " = " generate" ]; then
2174 echo " Running causal_testing GENERATE..."
75+ echo " Will write causal tests to: $CAUSAL_TESTS_OUTPUT_PATH "
76+
2277 python -m causal_testing generate \
23- --dag-path " $DAG_PATH " \
24- --output " $CAUSAL_TESTS " \
25- --estimator " $ESTIMATOR " \
26- --effect-type " $EFFECT_TYPE " \
27- --estimate-type " $ESTIMATE_TYPE " \
28- $( [ " $IGNORE_CYCLES " = " true " ] && echo " --ignore-cycles " ) \
29- --threads " $THREADS "
78+ -D " $DAG_PATH " \
79+ -o " $CAUSAL_TESTS_OUTPUT_PATH " \
80+ -e " $ESTIMATOR " \
81+ -T " $EFFECT_TYPE " \
82+ -E " $ESTIMATE_TYPE " \
83+ -t " $THREADS " \
84+ $( [ " $IGNORE_CYCLES " = " true " ] && echo " -i " )
3085
3186# --------------------------
3287# Test mode
3388# --------------------------
3489elif [ " $EXECUTION_MODE " = " test" ]; then
35- if [ ! -f " $CAUSAL_TESTS " ]; then
36- echo " Error : Causal tests file not found at $CAUSAL_TESTS "
90+ if [ ! -f " $CAUSAL_TESTS_INPUT_PATH " ]; then
91+ echo " ERROR : Causal tests file not found at $CAUSAL_TESTS_INPUT_PATH "
3792 exit 1
3893 fi
3994
4095 echo " Running causal_testing TEST..."
41- python -m causal_testing test \
42- --dag-path " $DAG_PATH " \
43- --data-paths " $DATA_PATH " \
44- --test-config " $CAUSAL_TESTS " \
45- --output " $CAUSAL_TEST_RESULTS " \
46- $( [ " $IGNORE_CYCLES " = " true" ] && echo " --ignore-cycles" ) \
47- $( [ " $VERBOSE " = " true" ] && echo " --verbose" ) \
48- $( [ -n " $QUERY " ] && echo " --query" " $QUERY " ) \
49- $( [ " $ADEQUACY " = " true" ] && echo " --adequacy --adequacy-bootstrap-size $BOOTSTRAP_SIZE " ) \
50- $( [ " $SILENT " = " true" ] && echo " --silent" ) \
51- $( [ " $BATCH_SIZE " != " 0" ] && echo " --batch-size $BATCH_SIZE " )
52- fi
96+ echo " Using causal tests from: $CAUSAL_TESTS_INPUT_PATH "
97+
98+ # DEBUG: Show which branch we're taking
99+ echo " === DEBUG: Adequacy Check ==="
100+ if [ " $ADEQUACY " = " true" ]; then
101+ echo " ADEQUACY is TRUE - will pass -a -b $BOOTSTRAP_SIZE "
102+ else
103+ echo " ADEQUACY is FALSE - will NOT pass -a -b flags"
104+ fi
105+ echo " ============================="
106+
107+ # Build command with adequacy flags only when ADEQUACY is true
108+ if [ " $ADEQUACY " = " true" ]; then
109+ echo " DEBUG: Executing WITH adequacy flags"
110+ python -m causal_testing test \
111+ -D " $DAG_PATH " \
112+ -d $DATA_PATHS \
113+ -t " $CAUSAL_TESTS_INPUT_PATH " \
114+ -o " $CAUSAL_TEST_RESULTS_PATH " \
115+ $( [ " $IGNORE_CYCLES " = " true" ] && echo " -i" ) \
116+ $( [ " $VERBOSE " = " true" ] && echo " -v" ) \
117+ $( [ -n " $QUERY " ] && [ " $QUERY " != " None" ] && echo " -q '$QUERY '" ) \
118+ -a -b $BOOTSTRAP_SIZE \
119+ $( [ " $SILENT " = " true" ] && echo " -s" ) \
120+ $( [ " $BATCH_SIZE " != " 0" ] && echo " --batch-size $BATCH_SIZE " )
121+ else
122+ echo " DEBUG: Executing WITHOUT adequacy flags"
123+ python -m causal_testing test \
124+ -D " $DAG_PATH " \
125+ -d $DATA_PATHS \
126+ -t " $CAUSAL_TESTS_INPUT_PATH " \
127+ -o " $CAUSAL_TEST_RESULTS_PATH " \
128+ $( [ " $IGNORE_CYCLES " = " true" ] && echo " -i" ) \
129+ $( [ " $VERBOSE " = " true" ] && echo " -v" ) \
130+ $( [ -n " $QUERY " ] && [ " $QUERY " != " None" ] && echo " -q '$QUERY '" ) \
131+ $( [ " $SILENT " = " true" ] && echo " -s" ) \
132+ $( [ " $BATCH_SIZE " != " 0" ] && echo " --batch-size $BATCH_SIZE " )
133+ fi
134+ fi
135+
136+ echo " Execution completed successfully"
0 commit comments