File size: 1,549 Bytes
3cd1076 | 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 | #!/bin/bash
set -e
REPO="SJTU-DENG-Lab/MBD-LMs-MultiTF-Datasets"
# Change DATA_ROOT to your preferred download location, or set DOWNLOAD_DIR in env.
DATA_ROOT="${DATA_ROOT:-$HOME/data/.cache/huggingface/datasets}"
DOWNLOAD_DIR="${DOWNLOAD_DIR:-${DATA_ROOT}/${REPO}}"
TARGET_LINK="dataset"
if ! command -v hf >/dev/null 2>&1; then
echo "Error: 'hf' CLI not found. Install it: pip install -U huggingface_hub" >&2
exit 1
fi
echo "============================================"
echo " Dataset Download & Link"
echo "============================================"
echo " Repository: ${REPO}"
echo " Download to: ${DOWNLOAD_DIR}"
echo " Symlink: $(pwd)/${TARGET_LINK}"
echo "============================================"
if [ -d "${DOWNLOAD_DIR}" ]; then
echo "Already downloaded, skipping."
else
echo "Downloading..."
mkdir -p "$(dirname "${DOWNLOAD_DIR}")"
hf download "${REPO}" --repo-type dataset --local-dir "${DOWNLOAD_DIR}"
echo "Download complete."
fi
# Remove existing symlink or directory
if [ -L "${TARGET_LINK}" ] || [ -d "${TARGET_LINK}" ]; then
rm -rf "${TARGET_LINK}"
fi
mkdir -p "${TARGET_LINK}"
# Symlink each jsonl file into dataset/
shopt -s nullglob
jsonl_files=("${DOWNLOAD_DIR}"/*.jsonl)
if [ ${#jsonl_files[@]} -eq 0 ]; then
echo "Warning: no .jsonl files found in ${DOWNLOAD_DIR}" >&2
else
for f in "${jsonl_files[@]}"; do
ln -s "${f}" "${TARGET_LINK}/$(basename "${f}")"
done
echo "Linked ${#jsonl_files[@]} .jsonl files into ${TARGET_LINK}/"
fi
echo "Done."
|