Download scripts/materialize_release.py from laion/inferredbugs-rootless-apptainer: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/datasets/laion/inferredbugs-rootless-apptainer/resolve/main/scripts/materialize_release.py
- Command line
-
hf download hf://datasets/laion/inferredbugs-rootless-apptainer/scripts/materialize_release.py
-
curl -L -o materialize_release.py https://huggingface.co/datasets/laion/inferredbugs-rootless-apptainer/resolve/main/scripts/materialize_release.py
1.25 kB
| #!/usr/bin/env python3 | |
| """Materialize Harbor task and SIF-cache views from this release.""" | |
| import argparse | |
| import json | |
| import os | |
| import subprocess | |
| import tempfile | |
| from pathlib import Path | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--release", type=Path, default=Path(__file__).resolve().parents[1]) | |
| parser.add_argument("--runtime-root", type=Path, required=True) | |
| args = parser.parse_args() | |
| release = args.release.resolve() | |
| runtime = args.runtime_root.resolve() | |
| if runtime.exists(): | |
| raise SystemExit(f"refusing to overwrite {runtime}") | |
| runtime.parent.mkdir(parents=True, exist_ok=True) | |
| with tempfile.TemporaryDirectory(prefix="harbor-runtime-", dir=runtime.parent) as temporary: | |
| stage = Path(temporary) / "runtime" | |
| stage.mkdir() | |
| subprocess.run( | |
| ["tar", "--use-compress-program=zstd", "-xf", str(release / "tasks.tar.zst"), "-C", str(stage)], | |
| check=True, | |
| ) | |
| sif_cache = stage / "sif-cache" | |
| sif_cache.mkdir() | |
| for line in (release / "manifests" / "task-sif-routing.jsonl").read_text().splitlines(): | |
| row = json.loads(line) | |
| (sif_cache / f"{row['task_id']}.sif").symlink_to(release / row["sif_image"]) | |
| os.replace(stage, runtime) | |
| print(f"materialized runtime at {runtime}") | |