File size: 1,339 Bytes
21c7db9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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