Backend: Fix analyze_single_patent to download PDF before reading from disk #477

Closed
opened 2026-03-27 22:22:41 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P2 - Backend / analyze_single_patent assumes local file path

Problem

analyze_single_patent constructs patents/{patent_id}.pdf and reads it from disk, but does not first download the PDF if it is absent. Calling this method on a patent that has not previously been fetched silently fails or raises an unhelpful FileNotFoundError.

Task

  • Integrate the download step into analyze_single_patent: if patents/{patent_id}.pdf does not exist, download it before parsing.
  • Alternatively, if the download is intentionally a separate step, add a clear guard clause with a descriptive error message explaining the prerequisite.
  • Update any relevant docstrings.

Acceptance Criteria

  • Calling analyze_single_patent on a patent with no local PDF either downloads it automatically or raises a clear, descriptive error.
  • No silent failures or unhandled FileNotFoundError.
  • Tests cover both the "file present" and "file absent" paths.
## Context Roadmap item: P2 - Backend / analyze_single_patent assumes local file path ## Problem `analyze_single_patent` constructs `patents/{patent_id}.pdf` and reads it from disk, but does not first download the PDF if it is absent. Calling this method on a patent that has not previously been fetched silently fails or raises an unhelpful FileNotFoundError. ## Task - Integrate the download step into `analyze_single_patent`: if `patents/{patent_id}.pdf` does not exist, download it before parsing. - Alternatively, if the download is intentionally a separate step, add a clear guard clause with a descriptive error message explaining the prerequisite. - Update any relevant docstrings. ## Acceptance Criteria - [ ] Calling `analyze_single_patent` on a patent with no local PDF either downloads it automatically or raises a clear, descriptive error. - [ ] No silent failures or unhandled `FileNotFoundError`. - [ ] Tests cover both the "file present" and "file absent" paths.
AI-Manager added the P2agent-readysmall labels 2026-03-27 22:22:41 +00:00
Author
Owner

Already implemented. analyze_single_patent() in SPARC/analyzer.py (lines 133-149) checks if the PDF exists on disk. If not, it looks up the cached PDF link and downloads it via SERP.save_patents() before proceeding. Closing as completed.

Already implemented. `analyze_single_patent()` in `SPARC/analyzer.py` (lines 133-149) checks if the PDF exists on disk. If not, it looks up the cached PDF link and downloads it via `SERP.save_patents()` before proceeding. 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#477