MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / _post_process

Function _post_process

demo/ai_scientists/web/app.py:403–427  ·  view source on GitHub ↗

Prepare sections, build zip, and compile PDF after a successful run.

(run: RunState)

Source from the content-addressed store, hash-verified

401
402
403def _post_process(run: RunState) -> None:
404 """Prepare sections, build zip, and compile PDF after a successful run."""
405 sections_dir = Path(run.workspace_output_dir) / "writer" / "sections"
406 artefact_dir = HOST_OUTPUTS_DIR / run.task_name / "artefacts"
407 artefact_dir.mkdir(parents=True, exist_ok=True)
408
409 # Step 1: Zip the sections directory + PRIMEarxiv.sty
410 zip_path = artefact_dir / "proposal_sources.zip"
411 _build_zip(sections_dir, zip_path)
412 run.zip_path = str(zip_path)
413 print(f"[POST] ZIP created: {zip_path}")
414
415 # Step 2: Compile PDF
416 pdf_tmp = _compile_pdf(sections_dir)
417 if pdf_tmp:
418 pdf_dest = artefact_dir / "proposal.pdf"
419 shutil.copy2(pdf_tmp, pdf_dest)
420 run.pdf_path = str(pdf_dest)
421 print(f"[POST] PDF saved: {pdf_dest}")
422 try:
423 shutil.rmtree(pdf_tmp.parent, ignore_errors=True)
424 except Exception:
425 pass
426 else:
427 print("[POST] PDF compilation failed or main.tex missing.")
428
429
430# ---------------------------------------------------------------------------

Callers 1

_run_agent_backgroundFunction · 0.85

Calls 2

_build_zipFunction · 0.85
_compile_pdfFunction · 0.85

Tested by

no test coverage detected