Download restore.sh from data-loader/simlingo-conda-env: direct link, hf CLI and curl.
- Browser
- Download file 2.42 kB
-
https://huggingface.co/datasets/data-loader/simlingo-conda-env/resolve/main/restore.sh
- Command line
-
hf download hf://datasets/data-loader/simlingo-conda-env/restore.sh
-
curl -L -o restore.sh https://huggingface.co/datasets/data-loader/simlingo-conda-env/resolve/main/restore.sh
2.42 kB
| set -Eeuo pipefail | |
| if [[ $# -lt 1 || $# -gt 2 || ( $# -eq 2 && "${2:-}" != --offline ) ]]; then | |
| echo 'Usage: bash restore.sh /absolute/path/to/environment [--offline]' >&2 | |
| exit 2 | |
| fi | |
| TARGET=$(readlink -m -- "$1") | |
| if [[ -e "$TARGET" && ( ! -d "$TARGET" || -n "$(ls -A "$TARGET")" ) ]]; then | |
| echo "Refusing to overwrite a nonempty environment: $TARGET" >&2 | |
| exit 2 | |
| fi | |
| SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) | |
| if [[ -f "$SCRIPT_DIR/SHA256SUMS" && -d "$SCRIPT_DIR/archives" ]]; then | |
| DEFAULT_CACHE=$SCRIPT_DIR | |
| else | |
| DEFAULT_CACHE=$SCRIPT_DIR/simlingo-env-files | |
| fi | |
| CACHE=${SIMLINGO_PACKAGE_CACHE:-$DEFAULT_CACHE} | |
| mkdir -p "$CACHE/archives" | |
| CACHE=$(cd "$CACHE" && pwd) | |
| BASE_URL="https://huggingface.co/datasets/data-loader/simlingo-conda-env/resolve/${SIMLINGO_ENV_REVISION:-main}" | |
| OFFLINE=${2:-} | |
| ARCHIVES=(archives/simlingo-linux-x86_64-py38-20261015.tar.gz.part-000 archives/simlingo-linux-x86_64-py38-20261015.tar.gz.part-001 archives/simlingo-linux-x86_64-py38-20261015.tar.gz.part-002 archives/simlingo-linux-x86_64-py38-20261015.tar.gz.part-003) | |
| METADATA=(manifest.json packages.json environment-info.json requirements-snapshot.txt restore-validation.json public-audit.json THIRD_PARTY_NOTICES.md) | |
| download() { | |
| local rel=$1 | |
| local file="$CACHE/$rel" | |
| if [[ "$OFFLINE" == --offline ]]; then | |
| test -f "$file" || { echo "Missing offline file: $rel" >&2; exit 2; } | |
| return | |
| fi | |
| if [[ "$rel" != SHA256SUMS && -f "$file" && -f "$CACHE/SHA256SUMS" ]]; then | |
| if (cd "$CACHE" && awk -v f="$rel" '$2 == f { print }' SHA256SUMS | sha256sum -c --status); then | |
| return | |
| fi | |
| fi | |
| curl --fail --location --retry 3 --connect-timeout 30 --continue-at - --output "$file.partial" "$BASE_URL/$rel" | |
| mv -- "$file.partial" "$file" | |
| } | |
| download SHA256SUMS | |
| for rel in "${METADATA[@]}" "${ARCHIVES[@]}"; do download "$rel"; done | |
| (cd "$CACHE" && sha256sum -c SHA256SUMS) | |
| mkdir -p "$TARGET" | |
| ARCHIVE_PATHS=() | |
| for rel in "${ARCHIVES[@]}"; do ARCHIVE_PATHS+=("$CACHE/$rel"); done | |
| cat "${ARCHIVE_PATHS[@]}" | tar --no-same-owner -xz -C "$TARGET" | |
| set +u | |
| source "$TARGET/bin/activate" | |
| set -u | |
| hash -r | |
| test "$(command -v python)" = "$TARGET/bin/python" | |
| python "$TARGET/bin/conda-unpack" | |
| python -c 'import sys, torch; print("Python:", sys.executable); print("PyTorch:", torch.__version__)' | |
| printf '\nEnvironment ready. In your shell run:\nsource %q/bin/activate\n' "$TARGET" | |