Skip to content

Commit bee759b

Browse files
committed
Discover Trace the Ace inputs by schema [run-full]
1 parent 97d2446 commit bee759b

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

.github/workflows/trace-ace-mastery.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,44 @@ jobs:
9696
shell: bash
9797
run: |
9898
set -euo pipefail
99-
FEATURES=$(find /tmp/trace_ace -type f -name 'train_features*.csv' | head -1)
100-
LABELS=$(find /tmp/trace_ace -type f -name 'train_labels*.csv' | head -1)
101-
TRANSCRIPTS=$(find /tmp/trace_ace -type d -name 'train_transcripts*' | head -1)
102-
test -n "$FEATURES" && test -n "$LABELS" && test -n "$TRANSCRIPTS"
99+
python - <<'PY'
100+
import csv, shlex
101+
from pathlib import Path
102+
103+
root = Path('/tmp/trace_ace/data')
104+
features = labels = transcript_dir = None
105+
inspected = 0
106+
for path in root.rglob('*.csv'):
107+
try:
108+
with path.open('r', encoding='utf-8-sig', errors='ignore', newline='') as f:
109+
header = next(csv.reader(f))
110+
except Exception:
111+
continue
112+
inspected += 1
113+
cols = set(header)
114+
if features is None and {'response_id', 'session_id', 'learning_objective'}.issubset(cols):
115+
features = path
116+
print('FEATURE HEADER', path, header)
117+
if labels is None and 'response_id' in cols and ({'is_correct'} <= cols or {'correct'} <= cols):
118+
labels = path
119+
print('LABEL HEADER', path, header)
120+
if transcript_dir is None and {'session_id', 'utterance_id', 'role', 'content', 'timestamp'}.issubset(cols):
121+
transcript_dir = path.parent
122+
print('TRANSCRIPT HEADER', path, header)
123+
if features and labels and transcript_dir:
124+
break
125+
if not (features and labels and transcript_dir):
126+
sample = [str(p) for p in list(root.rglob('*'))[:80]]
127+
raise SystemExit(f'Could not identify inputs by schema after {inspected} CSVs. Sample paths: {sample}')
128+
with open('/tmp/trace_ace/paths.env', 'w') as f:
129+
f.write('FEATURES=' + shlex.quote(str(features)) + '\n')
130+
f.write('LABELS=' + shlex.quote(str(labels)) + '\n')
131+
f.write('TRANSCRIPTS=' + shlex.quote(str(transcript_dir)) + '\n')
132+
print('resolved features:', features)
133+
print('resolved labels:', labels)
134+
print('resolved transcripts:', transcript_dir)
135+
PY
136+
source /tmp/trace_ace/paths.env
103137
LIMIT="${{ inputs.limit }}"
104138
LIMIT="${LIMIT:-0}"
105139
EXTRA=()

0 commit comments

Comments
 (0)