50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
"""Export the deliverable notebooks as LLM-readable report sources.
|
|
|
|
Executes each notebook fresh (widget defaults — or whatever defaults you edit in),
|
|
then writes both formats to exports/:
|
|
|
|
exports/<notebook>.html — human-reviewable, tables render
|
|
exports/<notebook>.md — leanest LLM input
|
|
|
|
Plotly figures export as JavaScript an LLM cannot read; each notebook's
|
|
machine-readable appendix section carries every number behind them.
|
|
|
|
Run from the project root: python scripts/export_report.py [name-filter]
|
|
An optional argument exports only notebooks whose filename contains it,
|
|
e.g. python scripts/export_report.py migration
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
NOTEBOOKS = [
|
|
ROOT / "notebooks" / "ctm_business_case_corrected.ipynb",
|
|
ROOT / "notebooks" / "ctm_migration_wfm.ipynb",
|
|
]
|
|
EXPORTS = ROOT / "exports"
|
|
|
|
|
|
def main() -> None:
|
|
picked = [nb for nb in NOTEBOOKS
|
|
if len(sys.argv) < 2 or sys.argv[1] in nb.name]
|
|
if not picked:
|
|
sys.exit(f"no notebook matches {sys.argv[1]!r}")
|
|
EXPORTS.mkdir(exist_ok=True)
|
|
for nb in picked:
|
|
for fmt in ("html", "markdown"):
|
|
subprocess.run(
|
|
[sys.executable, "-m", "nbconvert", "--execute",
|
|
"--to", fmt, "--output-dir", str(EXPORTS), str(nb)],
|
|
check=True, cwd=ROOT,
|
|
)
|
|
for p in sorted(EXPORTS.iterdir()):
|
|
if p.suffix in (".html", ".md"):
|
|
print(f"wrote {p.relative_to(ROOT)} ({p.stat().st_size / 1024:,.0f} KB)")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|