Emit notebook pages in draft packs
This commit is contained in:
parent
839590006a
commit
75f0b5c06a
|
|
@ -63,6 +63,7 @@ def run_doclift_bundle_demo(
|
||||||
"concept_count": len(ctx.concepts),
|
"concept_count": len(ctx.concepts),
|
||||||
"review_flags": list(ctx.review_flags),
|
"review_flags": list(ctx.review_flags),
|
||||||
"groundrecall_bundle_included": bool(groundrecall_bundle),
|
"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")
|
(pack_dir / "doclift_bundle_summary.json").write_text(json.dumps(summary, indent=2), encoding="utf-8")
|
||||||
return summary
|
return summary
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ from pathlib import Path
|
||||||
import json
|
import json
|
||||||
import yaml
|
import yaml
|
||||||
from .course_schema import NormalizedCourse, ConceptCandidate, DraftPack
|
from .course_schema import NormalizedCourse, ConceptCandidate, DraftPack
|
||||||
|
from .notebook_page import build_notebook_page_from_groundrecall_bundle
|
||||||
|
|
||||||
|
|
||||||
def build_source_corpus(course: NormalizedCourse) -> dict:
|
def build_source_corpus(course: NormalizedCourse) -> dict:
|
||||||
|
|
@ -76,7 +77,7 @@ def build_draft_pack(
|
||||||
pack_name = course.title.lower().replace(" ", "-")
|
pack_name = course.title.lower().replace(" ", "-")
|
||||||
supporting_artifacts = ["source_corpus.json", "knowledge_graph.json"]
|
supporting_artifacts = ["source_corpus.json", "knowledge_graph.json"]
|
||||||
if groundrecall_query_bundle is not None:
|
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 = {
|
pack = {
|
||||||
"name": pack_name,
|
"name": pack_name,
|
||||||
"display_name": course.title,
|
"display_name": course.title,
|
||||||
|
|
@ -140,6 +141,7 @@ def build_draft_pack(
|
||||||
}
|
}
|
||||||
if groundrecall_query_bundle is not None:
|
if groundrecall_query_bundle is not None:
|
||||||
attribution["groundrecall_query_bundle"] = groundrecall_query_bundle
|
attribution["groundrecall_query_bundle"] = groundrecall_query_bundle
|
||||||
|
attribution["notebook_page"] = build_notebook_page_from_groundrecall_bundle(groundrecall_query_bundle)
|
||||||
return DraftPack(
|
return DraftPack(
|
||||||
pack=pack,
|
pack=pack,
|
||||||
concepts=concepts_yaml,
|
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),
|
json.dumps(pack.attribution["groundrecall_query_bundle"], indent=2),
|
||||||
encoding="utf-8",
|
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:
|
def write_source_corpus(course: NormalizedCourse, outdir: str | Path) -> None:
|
||||||
|
|
|
||||||
|
|
@ -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")
|
pack_yaml = (tmp_path / "pack.yaml").read_text(encoding="utf-8")
|
||||||
bundle_payload = (tmp_path / "groundrecall_query_bundle.json").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 "groundrecall_query_bundle.json" in pack_yaml
|
||||||
|
assert "notebook_page.json" in pack_yaml
|
||||||
assert '"bundle_kind": "groundrecall_query_bundle"' in bundle_payload
|
assert '"bundle_kind": "groundrecall_query_bundle"' in bundle_payload
|
||||||
|
assert '"page_kind": "didactopus_notebook_page"' in notebook_payload
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue