generated from Pseudo-Lab/builder-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_pipeline.sh
More file actions
171 lines (148 loc) · 4.22 KB
/
run_pipeline.sh
File metadata and controls
171 lines (148 loc) · 4.22 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
# ==============================================================================
# TableMagnifier - JSON Pipeline
# ==============================================================================
#
# Usage:
# ./run_pipeline.sh [INPUT_JSON] [OPTIONS]
#
# Examples:
# ./run_pipeline.sh test_public.json --domain public
# ./run_pipeline.sh test_business.json --domain business --provider openai
# ./run_pipeline.sh --input data.json --output-dir output_custom
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Default Configuration
INPUT_JSON=""
OUTPUT_DIR=""
PROVIDER="claude"
MODEL="claude-sonnet-4-5"
DOMAIN="public"
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
show_help() {
cat << EOF
Usage: $0 [INPUT_JSON] [OPTIONS]
TableMagnifier JSON Pipeline Runner
Arguments:
INPUT_JSON Input JSON file path (optional, can use --input instead)
Options:
--input FILE Input JSON file
--output-dir DIR Output directory (default: output_{domain})
--provider PROVIDER LLM provider: claude, openai, gemini (default: claude)
--model MODEL Model name (default: claude-sonnet-4-5)
--domain DOMAIN Domain: public, business, finance, medical, academic (default: public)
--qa-only Generate QA only (skip table generation)
--skip-qa Skip QA generation (table only)
--upload-to-notion Upload results to Notion
-h, --help Show this help
Examples:
# Public domain with Claude
$0 test_public.json --domain public
# Business domain with OpenAI
$0 test_business.json --domain business --provider openai --model gpt-4o
# Finance domain, QA only mode
$0 test_finance.json --domain finance --qa-only
# Custom output directory
$0 data.json --output-dir my_output --domain medical
EOF
}
# Parse first argument as JSON file if it ends with .json
if [[ "$1" == *.json ]]; then
INPUT_JSON="$1"
shift
fi
# Parse remaining arguments
EXTRA_ARGS=""
while [[ $# -gt 0 ]]; do
case $1 in
--input)
INPUT_JSON="$2"
shift 2
;;
--output-dir)
OUTPUT_DIR="$2"
shift 2
;;
--provider)
PROVIDER="$2"
shift 2
;;
--model)
MODEL="$2"
shift 2
;;
--domain)
DOMAIN="$2"
shift 2
;;
-h|--help)
show_help
exit 0
;;
*)
EXTRA_ARGS="$EXTRA_ARGS $1"
shift
;;
esac
done
# Set default output directory based on domain
if [[ -z "$OUTPUT_DIR" ]]; then
OUTPUT_DIR="output_${DOMAIN}"
fi
# Validate input
if [[ -z "$INPUT_JSON" ]]; then
echo -e "${YELLOW}[WARN]${NC} No input JSON specified."
show_help
exit 1
fi
if [[ ! -f "$INPUT_JSON" ]]; then
echo -e "${YELLOW}[ERROR]${NC} Input file not found: $INPUT_JSON"
exit 1
fi
echo "=============================================="
echo " TableMagnifier - JSON Pipeline"
echo "=============================================="
echo "Input JSON: $INPUT_JSON"
echo "Output Dir: $OUTPUT_DIR"
echo "Provider: $PROVIDER"
echo "Model: $MODEL"
echo "Domain: $DOMAIN"
echo ""
# Check API keys based on provider
case $PROVIDER in
claude|anthropic)
if [[ -z "$ANTHROPIC_API_KEY" ]]; then
echo -e "${YELLOW}[WARN]${NC} ANTHROPIC_API_KEY is not set."
fi
;;
openai)
if [[ -z "$OPENAI_API_KEY" ]]; then
echo -e "${YELLOW}[WARN]${NC} OPENAI_API_KEY is not set."
fi
;;
gemini|google)
if [[ -z "$GOOGLE_API_KEY" ]]; then
echo -e "${YELLOW}[WARN]${NC} GOOGLE_API_KEY is not set."
fi
;;
esac
echo -e "${GREEN}[INFO]${NC} Starting pipeline..."
echo ""
# Run the pipeline
uv run python run_pipeline_json.py \
--input "$INPUT_JSON" \
--output-dir "$OUTPUT_DIR" \
--provider "$PROVIDER" \
--model "$MODEL" \
--domain "$DOMAIN" \
$EXTRA_ARGS
echo ""
echo -e "${GREEN}[INFO]${NC} Pipeline completed. Results saved to: $OUTPUT_DIR/"
echo ""
echo "To upload results to Notion:"
echo " python upload_to_notion_from_json.py $OUTPUT_DIR"