Download src/hackable/paths.py from psidharth567/neuralese_temp: direct link, hf CLI and curl.
- Browser
- Download file 1.91 kB
-
https://huggingface.co/psidharth567/neuralese_temp/resolve/main/src/hackable/paths.py
- Command line
-
hf download hf://psidharth567/neuralese_temp/src/hackable/paths.py
-
curl -L -o paths.py https://huggingface.co/psidharth567/neuralese_temp/resolve/main/src/hackable/paths.py
1.91 kB
| from __future__ import annotations | |
| from dataclasses import dataclass | |
| from pathlib import Path | |
| from .utils import repository_root | |
| class StorageLayout: | |
| root: Path | |
| datasets: Path | |
| models: Path | |
| hf: Path | |
| artifacts: Path | |
| runs: Path | |
| sweeps: Path | |
| evals: Path | |
| logs: Path | |
| wandb: Path | |
| def storage_layout(cache_dir: str | Path = "cache") -> StorageLayout: | |
| root = _resolve_storage_root(cache_dir) | |
| artifacts = root / "artifacts" | |
| logs = root / "logs" | |
| return StorageLayout( | |
| root=root, | |
| datasets=root / "datasets", | |
| models=root / "models", | |
| hf=root / "hf", | |
| artifacts=artifacts, | |
| runs=artifacts / "runs", | |
| sweeps=artifacts / "sweeps", | |
| evals=artifacts / "eval", | |
| logs=logs, | |
| wandb=logs / "wandb", | |
| ) | |
| def ensure_storage_layout(cache_dir: str | Path = "cache") -> StorageLayout: | |
| layout = storage_layout(cache_dir) | |
| for path in ( | |
| layout.root, | |
| layout.datasets, | |
| layout.models, | |
| layout.hf, | |
| layout.artifacts, | |
| layout.runs, | |
| layout.sweeps, | |
| layout.evals, | |
| layout.logs, | |
| layout.wandb, | |
| ): | |
| path.mkdir(parents=True, exist_ok=True) | |
| return layout | |
| def resolve_storage_path(path: str | Path, cache_dir: str | Path = "cache") -> Path: | |
| candidate = Path(path) | |
| if candidate.is_absolute(): | |
| return candidate.resolve() | |
| repo = repository_root() | |
| cache_root = _resolve_storage_root(cache_dir) | |
| if candidate.parts and candidate.parts[0] == cache_root.name: | |
| return (repo / candidate).resolve() | |
| return (cache_root / candidate).resolve() | |
| def _resolve_storage_root(cache_dir: str | Path) -> Path: | |
| candidate = Path(cache_dir) | |
| if candidate.is_absolute(): | |
| return candidate.resolve() | |
| return (repository_root() / candidate).resolve() | |