Download tests/scripts/test_kaggle_train.py from Kolgrim/hades: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/Kolgrim/hades/resolve/main/tests/scripts/test_kaggle_train.py
- Command line
-
hf download hf://Kolgrim/hades/tests/scripts/test_kaggle_train.py
-
curl -L -o test_kaggle_train.py https://huggingface.co/Kolgrim/hades/resolve/main/tests/scripts/test_kaggle_train.py
1.06 kB
| import importlib.util | |
| from pathlib import Path | |
| spec = importlib.util.spec_from_file_location("kaggle_train", Path("scripts/kaggle_train.py")) | |
| kt = importlib.util.module_from_spec(spec) | |
| spec.loader.exec_module(kt) | |
| def test_find_dir_with_marker_any_mount_layout(tmp_path): | |
| for layout in ("hades-corpus-v1", "datasets/selbymashiki/hades-corpus-v1"): | |
| root = tmp_path / layout.replace("/", "_") | |
| target = root / layout / "processed" | |
| target.mkdir(parents=True) | |
| (target / "manifest.json").write_text("{}") | |
| assert kt.find_dir_with(root, "manifest.json") == target | |
| def test_find_dir_with_missing_returns_none(tmp_path): | |
| assert kt.find_dir_with(tmp_path, "manifest.json") is None | |
| def test_latest_checkpoints_are_collected(tmp_path): | |
| (tmp_path / "a").mkdir() | |
| for name in ("step_0000100.pt", "step_0000200.pt", "best.pt", "step_0000300.tmp"): | |
| (tmp_path / "a" / name).write_bytes(b"x") | |
| assert sorted(p.name for p in kt.checkpoint_files(tmp_path)) == ["best.pt", "step_0000100.pt", "step_0000200.pt"] | |