Emit notebook pages in draft packs

This commit is contained in:
welsberr 2026-04-28 00:15:59 -04:00
parent 839590006a
commit 75f0b5c06a
3 changed files with 12 additions and 1 deletions

View File

@ -63,6 +63,7 @@ def run_doclift_bundle_demo(
"concept_count": len(ctx.concepts),
"review_flags": list(ctx.review_flags),
"groundrecall_bundle_included": bool(groundrecall_bundle),
"notebook_page_included": bool(groundrecall_bundle),
}
(pack_dir / "doclift_bundle_summary.json").write_text(json.dumps(summary, indent=2), encoding="utf-8")
return summary

View File

@ -4,6 +4,7 @@ from pathlib import Path
import json
import yaml
from .course_schema import NormalizedCourse, ConceptCandidate, DraftPack
from .notebook_page import build_notebook_page_from_groundrecall_bundle
def build_source_corpus(course: NormalizedCourse) -> dict:
@ -76,7 +77,7 @@ def build_draft_pack(
pack_name = course.title.lower().replace(" ", "-")
supporting_artifacts = ["source_corpus.json", "knowledge_graph.json"]
if groundrecall_query_bundle is not None:
supporting_artifacts.append("groundrecall_query_bundle.json")
supporting_artifacts.extend(["groundrecall_query_bundle.json", "notebook_page.json"])
pack = {
"name": pack_name,
"display_name": course.title,
@ -140,6 +141,7 @@ def build_draft_pack(
}
if groundrecall_query_bundle is not None:
attribution["groundrecall_query_bundle"] = groundrecall_query_bundle
attribution["notebook_page"] = build_notebook_page_from_groundrecall_bundle(groundrecall_query_bundle)
return DraftPack(
pack=pack,
concepts=concepts_yaml,
@ -170,6 +172,11 @@ def write_draft_pack(pack: DraftPack, outdir: str | Path) -> None:
json.dumps(pack.attribution["groundrecall_query_bundle"], indent=2),
encoding="utf-8",
)
if isinstance(pack.attribution.get("notebook_page"), dict):
(out / "notebook_page.json").write_text(
json.dumps(pack.attribution["notebook_page"], indent=2),
encoding="utf-8",
)
def write_source_corpus(course: NormalizedCourse, outdir: str | Path) -> None:

View File

@ -51,5 +51,8 @@ def test_emit_pack_can_write_groundrecall_query_bundle(tmp_path: Path) -> None:
pack_yaml = (tmp_path / "pack.yaml").read_text(encoding="utf-8")
bundle_payload = (tmp_path / "groundrecall_query_bundle.json").read_text(encoding="utf-8")
notebook_payload = (tmp_path / "notebook_page.json").read_text(encoding="utf-8")
assert "groundrecall_query_bundle.json" in pack_yaml
assert "notebook_page.json" in pack_yaml
assert '"bundle_kind": "groundrecall_query_bundle"' in bundle_payload
assert '"page_kind": "didactopus_notebook_page"' in notebook_payload