Download scripts/train/io_utils.py from jlai300/FitGround: direct link, hf CLI and curl.
- Browser
- Download file 551 Bytes
-
https://huggingface.co/datasets/jlai300/FitGround/resolve/main/scripts/train/io_utils.py
- Command line
-
hf download hf://datasets/jlai300/FitGround/scripts/train/io_utils.py
-
curl -L -o io_utils.py https://huggingface.co/datasets/jlai300/FitGround/resolve/main/scripts/train/io_utils.py
551 Bytes
| """Load training artifacts.""" | |
| from __future__ import annotations | |
| import json | |
| from pathlib import Path | |
| from typing import Any | |
| def read_jsonl(path: Path) -> list[dict[str, Any]]: | |
| rows = [] | |
| with path.open(encoding="utf-8") as fh: | |
| for line in fh: | |
| line = line.strip() | |
| if line: | |
| rows.append(json.loads(line)) | |
| return rows | |
| def write_json(path: Path, payload: Any) -> None: | |
| path.parent.mkdir(parents=True, exist_ok=True) | |
| path.write_text(json.dumps(payload, indent=2), encoding="utf-8") | |