import requests, os, time backend = "http://localhost:8000" uploads = os.path.join(os.path.dirname(__file__), "..", "uploads") reports = os.path.join(os.path.dirname(__file__), "..", "reports") os.makedirs(reports, exist_ok=True) for i in range(14, 21): paper = f"paper_{i:02d}.pdf" path = os.path.join(uploads, paper) report = os.path.join(reports, f"{paper[:-4]}_report.pdf") print(f"{paper}: uploading...") with open(path, "rb") as f: r = requests.post( f"{backend}/analyze", files={"file": (paper, f, "application/pdf")} ) if r.ok: job_id = r.json()["job_id"] print(f" job: {job_id}") for _ in range(90): time.sleep(5) j = requests.get(f"{backend}/jobs/{job_id}").json() status = j.get("status", "") print(f" status: {status}") if status == "completed": r2 = requests.get(f"{backend}/reports/{job_id}/pdf", stream=True) with open(report, "wb") as out: for chunk in r2.iter_content(): out.write(chunk) print(f" saved: {report}") break elif status in ["failed"]: break print()