| from __future__ import annotations |
|
|
| import json |
| import re |
| from pathlib import Path |
|
|
|
|
| ROOT = Path(__file__).resolve().parents[1] |
| NOTEBOOK = ROOT / "PolyGuard_SFT_GRPO_One_Run_Runner.ipynb" |
|
|
|
|
| def test_root_one_run_runner_notebook_covers_full_pipeline_without_secrets() -> None: |
| assert NOTEBOOK.exists() |
| payload = json.loads(NOTEBOOK.read_text(encoding="utf-8")) |
| assert payload.get("nbformat") == 4 |
|
|
| source = "\n".join( |
| "".join(cell.get("source", [])) |
| for cell in payload.get("cells", []) |
| if isinstance(cell, dict) |
| ) |
| assert "POLYGUARD_ONE_RUN_RUNNER" in source |
|
|
| required_markers = [ |
| "scripts/bootstrap_data.py", |
| "scripts/build_training_corpus.py", |
| "scripts/train_sft_trl.py", |
| "scripts/train_grpo_trl.py", |
| "scripts/deploy_training_space.py", |
| "scripts/pull_training_artifacts.py", |
| "scripts/generate_hf_training_report.py", |
| "scripts/test_inference_postsave.py", |
| "scripts/deploy_space_api.py", |
| ] |
| for marker in required_markers: |
| assert marker in source |
|
|
| assert not re.search(r"hf_[A-Za-z0-9]{20,}", source) |
|
|
|
|
| def test_readme_points_colab_link_at_root_runner_notebook() -> None: |
| readme = (ROOT / "README.md").read_text(encoding="utf-8") |
| assert "PolyGuard_SFT_GRPO_One_Run_Runner.ipynb" in readme |
|
|