#!/bin/bash # Download benchmark data from HF Bucket on startup, then launch the API. # Bucket is the single source of truth for parquet/registry files. set -euo pipefail BUCKET="${HF_BUCKET:-stasaking/blood-brain-benchmark}" DATA_DIR="/app/data" mkdir -p "$DATA_DIR" python -c " from huggingface_hub import list_bucket_tree, download_bucket_files import os bucket = '$BUCKET' data_dir = '$DATA_DIR' files = list(list_bucket_tree(bucket)) download_list = [] for f in files: if f.path.endswith(('.parquet', '.json')): local_path = os.path.join(data_dir, f.path) os.makedirs(os.path.dirname(local_path) or data_dir, exist_ok=True) download_list.append((f.path, local_path)) print(f'Downloading {len(download_list)} files from bucket {bucket}...') download_bucket_files(bucket, files=download_list) for _, lp in download_list: print(f' {lp}: {os.path.getsize(lp)/1e6:.2f} MB') print('Bucket sync complete.') " export BENCHMARK_DATA_DIR="$DATA_DIR" exec uvicorn main:app --host 0.0.0.0 --port 7860 --workers 1 --timeout-keep-alive 5