#!/bin/bash
set -e

INPUT_DIR="/workspace/input"
OUTPUT_DIR="/workspace/output"
INPUT_JSON="${INPUT_DIR}/task.json"
OUTPUT_JSON="${OUTPUT_DIR}/result.json"

# Allow overrides via env vars
INPUT_JSON="${PERF_INPUT:-$INPUT_JSON}"
OUTPUT_JSON="${PERF_OUTPUT:-$OUTPUT_JSON}"

if [ ! -f "$INPUT_JSON" ]; then
    echo "ERROR: input file not found: $INPUT_JSON"
    exit 1
fi

mkdir -p "$(dirname "$OUTPUT_JSON")"

exec python3 /workspace/perf/perf.py --input "$INPUT_JSON" --output "$OUTPUT_JSON"
