evolve / openevolve-fixed /examples /ADRS /llm_sql /fetch_datasets.sh
zhouk777's picture
Upload folder using huggingface_hub
ea8c728 verified
Raw
History Blame Contribute Delete
2.55 kB
#!/usr/bin/env bash
# Populate datasets/ for llm_sql (same CSVs as CORAL / skydiscover).
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DEST="$HERE/datasets"
# Hugging Face mirror used by skydiscover:
# https://github.com/skydiscover-ai/skydiscover/blob/main/benchmarks/ADRS/llm_sql/evaluator/download_dataset.sh
BASE_URL="https://huggingface.co/datasets/f20180301/adrs-data/resolve/main/llm_sql"
REQUIRED=(movies.csv beer.csv BIRD.csv PDMX.csv products.csv)
count_csv() {
local n=0
local f
for f in "${REQUIRED[@]}"; do
[[ -f "$DEST/$f" ]] && ((++n)) || true
done
echo "$n"
}
try_copy() {
local src="$1"
[[ -d "$src" ]] || return 1
mkdir -p "$DEST"
local ok=0
local f
for f in "${REQUIRED[@]}"; do
if [[ -f "$src/$f" ]]; then
cp -f "$src/$f" "$DEST/$f"
((++ok)) || true
fi
done
if [[ "$(count_csv)" -eq 5 ]]; then
echo "Copied 5 CSVs from: $src"
ls -lh "$DEST"/*.csv
return 0
fi
return 1
}
try_download() {
mkdir -p "$DEST"
local f url
for f in "${REQUIRED[@]}"; do
url="${BASE_URL}/datasets/${f}"
echo "Downloading ${f} ..."
if command -v wget >/dev/null 2>&1; then
wget -q --show-progress -O "$DEST/$f" "$url"
elif command -v curl >/dev/null 2>&1; then
curl -fsSL -o "$DEST/$f" "$url"
else
echo "ERROR: need wget or curl to download datasets." >&2
return 1
fi
done
if [[ "$(count_csv)" -eq 5 ]]; then
echo "Downloaded 5 CSVs into $DEST"
ls -lh "$DEST"/*.csv
return 0
fi
return 1
}
# 1) Explicit override
if [[ -n "${CORAL_LLM_SQL_DATASETS:-}" ]]; then
try_copy "${CORAL_LLM_SQL_DATASETS}" && exit 0
fi
# 2) Sibling CORAL checkout (HERE = .../openevolve-fixed/examples/ADRS/llm_sql → ../../../../ = monorepo root e.g. 17_coreal)
try_copy "$HERE/../../../../CORAL/examples/ADRS/llm_sql/eval/datasets" && exit 0
# 3) CORAL_ROOT env
if [[ -n "${CORAL_ROOT:-}" ]]; then
try_copy "${CORAL_ROOT}/examples/ADRS/llm_sql/eval/datasets" && exit 0
fi
# 4) One level shallower (if openevolve-fixed not nested the same way)
try_copy "$HERE/../../../CORAL/examples/ADRS/llm_sql/eval/datasets" && exit 0
# 5) Network fetch (same source as skydiscover download_dataset.sh)
echo "No local CORAL datasets dir with all 5 CSVs; downloading from Hugging Face..."
if try_download; then
exit 0
fi
echo "Failed to obtain datasets." >&2
echo "Put these files under: $DEST/" >&2
echo " ${REQUIRED[*]}" >&2
echo "Or set CORAL_LLM_SQL_DATASETS to a directory that contains them." >&2
exit 1