Spaces:
Runtime error
Runtime error
Download file_storage.py from datasysdev/trl-lora-without-regret: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/datasysdev/trl-lora-without-regret/resolve/9add9b3d02f606a68e3b0482a265d380ece72f8c/file_storage.py
- Command line
-
hf download hf://spaces/datasysdev/trl-lora-without-regret@9add9b3d02f606a68e3b0482a265d380ece72f8c/file_storage.py
-
curl -L -o file_storage.py https://huggingface.co/spaces/datasysdev/trl-lora-without-regret/resolve/9add9b3d02f606a68e3b0482a265d380ece72f8c/file_storage.py
1.1 kB
| from pathlib import Path | |
| try: # absolute imports when installed | |
| from trackio.utils import MEDIA_DIR | |
| except ImportError: # relative imports for local execution on Spaces | |
| from utils import MEDIA_DIR | |
| class FileStorage: | |
| def get_project_media_path( | |
| project: str, | |
| run: str | None = None, | |
| step: int | None = None, | |
| filename: str | None = None, | |
| ) -> Path: | |
| if filename is not None and step is None: | |
| raise ValueError("filename requires step") | |
| if step is not None and run is None: | |
| raise ValueError("step requires run") | |
| path = MEDIA_DIR / project | |
| if run: | |
| path /= run | |
| if step is not None: | |
| path /= str(step) | |
| if filename: | |
| path /= filename | |
| return path | |
| def init_project_media_path( | |
| project: str, run: str | None = None, step: int | None = None | |
| ) -> Path: | |
| path = FileStorage.get_project_media_path(project, run, step) | |
| path.mkdir(parents=True, exist_ok=True) | |
| return path | |