Spaces:
Sleeping
Sleeping
Download architect/private_artifacts.py from refaelz/legacy-code-challenge-v2: direct link, hf CLI and curl.
- Browser
- Download file 854 Bytes
-
https://huggingface.co/spaces/refaelz/legacy-code-challenge-v2/resolve/main/architect/private_artifacts.py
- Command line
-
hf download hf://spaces/refaelz/legacy-code-challenge-v2/architect/private_artifacts.py
-
curl -L -o private_artifacts.py https://huggingface.co/spaces/refaelz/legacy-code-challenge-v2/resolve/main/architect/private_artifacts.py
854 Bytes
| """Resolve server-side artifacts stored outside student workspaces.""" | |
| from __future__ import annotations | |
| import hashlib | |
| from pathlib import Path | |
| def private_workspace_dir(workspace_path: str | Path) -> Path: | |
| from architect.repo_cloner import WORKSPACES_DIR | |
| workspace = Path(workspace_path).resolve() | |
| root = Path(WORKSPACES_DIR).resolve() | |
| relative = workspace.relative_to(root) | |
| if ".private" in relative.parts: | |
| raise ValueError("Private artifacts cannot be nested as a student workspace") | |
| key = hashlib.sha256(relative.as_posix().encode("utf-8")).hexdigest() | |
| return root / ".private" / key | |
| def ensure_private_workspace_dir(workspace_path: str | Path) -> Path: | |
| directory = private_workspace_dir(workspace_path) | |
| directory.mkdir(parents=True, exist_ok=True) | |
| directory.chmod(0o700) | |
| return directory | |