Download code/ampd/isolation_runtime.py from fryabcfry/cs4486-amp-pd-checkpoints: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/fryabcfry/cs4486-amp-pd-checkpoints/resolve/main/code/ampd/isolation_runtime.py
- Command line
-
hf download hf://fryabcfry/cs4486-amp-pd-checkpoints/code/ampd/isolation_runtime.py
-
curl -L -o isolation_runtime.py https://huggingface.co/fryabcfry/cs4486-amp-pd-checkpoints/resolve/main/code/ampd/isolation_runtime.py
1.03 kB
| """Explicit inference isolation backends for reproducible teammate runs.""" | |
| from __future__ import annotations | |
| import os | |
| from pathlib import Path | |
| import platform | |
| import sys | |
| def isolation_backend(): | |
| value = os.environ.get("AMPD_ISOLATION_BACKEND", "macos") | |
| if value not in {"macos", "python-audit"}: | |
| raise ValueError("AMPD_ISOLATION_BACKEND must be macos or python-audit") | |
| if value == "macos" and platform.system() != "Darwin": | |
| raise RuntimeError("OS sandbox requires macOS. For an explicitly weaker portable test, set AMPD_ISOLATION_BACKEND=python-audit.") | |
| return value | |
| def prediction_command(bundle, script): | |
| bundle, script = Path(bundle).resolve(), Path(script).resolve() | |
| if isolation_backend() == "macos": | |
| return ["/usr/bin/sandbox-exec", "-f", str(bundle/"sandbox.sb"), | |
| sys.executable, str(script), "--bundle", str(bundle)] | |
| return [sys.executable, str(script.parent/"predict_audit_guard.py"), | |
| "--script", str(script), "--bundle", str(bundle)] | |