ci-profile / scripts /run.sh
qgallouedec's picture
qgallouedec HF Staff
Upload folder using huggingface_hub
745627a verified
Raw History Blame Contribute Delete
1.39 kB
#!/bin/bash
# HF Jobs entrypoint. Expects the dataset repo mounted at /profile (read-only) and HF_TOKEN set.
set -euo pipefail
REPO_ID=${REPO_ID:-trl-internal-testing/ci-profile}
export TQDM_DISABLE=1 PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True PYTORCH_ALLOC_CONF=expandable_segments:True
apt-get update && apt-get install -y git
pip install uv
git clone --depth 1 https://github.com/huggingface/trl.git /trl
cd /trl
uv venv --python 3.12
source .venv/bin/activate
uv pip install ".[dev]"
SHA=$(git rev-parse HEAD)
DATE=$(date -u +%Y-%m-%d)
NAME="${DATE}_${SHA:0:8}"
export PROFILE_OUT=/tmp/$NAME.jsonl
export PROFILE_META=$(python -c "
import json, torch, transformers
print(json.dumps({'date': '$DATE', 'sha': '$SHA', 'torch': torch.__version__,
'transformers': transformers.__version__, 'gpu': torch.cuda.get_device_name()}))")
export PYTHONPATH=/profile/scripts
# Serial on purpose: parallel workers share the GPU and distort per-test timings.
pytest -p profile_plugin -m "not slow and not low_priority" -v -p no:cacheprovider tests || true
python /profile/scripts/report.py "$PROFILE_OUT" /profile/data > /tmp/$NAME.md
cat /tmp/$NAME.md
hf upload "$REPO_ID" "$PROFILE_OUT" "data/$NAME.jsonl" --repo-type dataset --commit-message "Profile $NAME"
hf upload "$REPO_ID" /tmp/$NAME.md "summaries/$NAME.md" --repo-type dataset --commit-message "Summary $NAME"