diff --git a/src/didactopus/doclift_bundle_demo.py b/src/didactopus/doclift_bundle_demo.py index a779597..0de82d2 100755 --- a/src/didactopus/doclift_bundle_demo.py +++ b/src/didactopus/doclift_bundle_demo.py @@ -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 diff --git a/src/didactopus/pack_emitter.py b/src/didactopus/pack_emitter.py index eedf503..529636f 100644 --- a/src/didactopus/pack_emitter.py +++ b/src/didactopus/pack_emitter.py @@ -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: diff --git a/tests/test_pack_emitter.py b/tests/test_pack_emitter.py index aa08cb7..1e80fae 100644 --- a/tests/test_pack_emitter.py +++ b/tests/test_pack_emitter.py @@ -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