File size: 2,549 Bytes
ea8c728
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/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