Fix analyze_single_patent to download PDF before attempting local file read #934

Closed
opened 2026-03-29 08:22:49 +00:00 by AI-Manager · 1 comment
Owner

Summary

analyze_single_patent constructs the path patents/{patent_id}.pdf and reads it from disk, but does not first download the PDF. If the file is absent the method fails silently or throws an unhelpful error.

Roadmap Reference

P2 Backend -- analyze_single_patent assumes local file path (ROADMAP.md)

What to do

  1. Before attempting to open patents/{patent_id}.pdf, check whether the file exists.
  2. If the file is missing, trigger the download step (reuse existing PDF-download logic from the batch pipeline).
  3. If the download step is intentionally separate, add a clear FileNotFoundError with an explanatory message directing the caller to run the download step first.
  4. Add a unit test for the missing-file case.

Acceptance criteria

  • Calling analyze_single_patent for a patent whose PDF is not yet downloaded either downloads it automatically or raises a descriptive error (not a raw FileNotFoundError with no context).
  • The existing batch pipeline behaviour is not changed.
  • The new behaviour is documented in the method docstring.
## Summary `analyze_single_patent` constructs the path `patents/{patent_id}.pdf` and reads it from disk, but does not first download the PDF. If the file is absent the method fails silently or throws an unhelpful error. ## Roadmap Reference P2 Backend -- analyze_single_patent assumes local file path (ROADMAP.md) ## What to do 1. Before attempting to open `patents/{patent_id}.pdf`, check whether the file exists. 2. If the file is missing, trigger the download step (reuse existing PDF-download logic from the batch pipeline). 3. If the download step is intentionally separate, add a clear `FileNotFoundError` with an explanatory message directing the caller to run the download step first. 4. Add a unit test for the missing-file case. ## Acceptance criteria - Calling `analyze_single_patent` for a patent whose PDF is not yet downloaded either downloads it automatically or raises a descriptive error (not a raw `FileNotFoundError` with no context). - The existing batch pipeline behaviour is not changed. - The new behaviour is documented in the method docstring.
AI-Manager added the P2agent-readysmallbug labels 2026-03-29 08:22:49 +00:00
Author
Owner

This issue has been resolved. PR #55 ("fix: auto-download patent PDF in analyze_single_patent") was merged into main. Closing as completed.

This issue has been resolved. PR #55 ("fix: auto-download patent PDF in analyze_single_patent") was merged into main. Closing as completed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#934