Spaces:
Sleeping
Sleeping
Download src/capstone/data/paths.py from cs32-2/report-demo: direct link, hf CLI and curl.
- Browser
- Download file 847 Bytes
-
https://huggingface.co/spaces/cs32-2/report-demo/resolve/main/src/capstone/data/paths.py
- Command line
-
hf download hf://spaces/cs32-2/report-demo/src/capstone/data/paths.py
-
curl -L -o paths.py https://huggingface.co/spaces/cs32-2/report-demo/resolve/main/src/capstone/data/paths.py
847 Bytes
| """Data path resolution for the capstone project.""" | |
| from __future__ import annotations | |
| import os | |
| from pathlib import Path | |
| def get_data_root(explicit: str | Path | None = None) -> Path: | |
| """Return the MedMNIST data root, creating it if it does not exist.""" | |
| if explicit is not None: | |
| root = Path(explicit) | |
| elif env_root := os.environ.get("CAPSTONE_DATA_ROOT"): | |
| root = Path(env_root) | |
| else: | |
| root = _find_repo_root() / "data" / "medmnist" | |
| root.mkdir(parents=True, exist_ok=True) | |
| return root | |
| def _find_repo_root() -> Path: | |
| current = Path(__file__).resolve().parent | |
| for directory in (current, *current.parents): | |
| if (directory / "pyproject.toml").is_file(): | |
| return directory | |
| msg = "Could not find repository root (no pyproject.toml found)" | |
| raise RuntimeError(msg) | |