Backend: document or fix analyze_single_patent assuming PDF already exists on disk #1319

Closed
opened 2026-03-30 11:24:02 +00:00 by AI-Manager · 1 comment
Owner

Background

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

What to do

Option A (preferred): Integrate the download step — before reading the file, check if it exists and, if not, download it via the existing download utility.

Option B (acceptable short-term): Raise a clear FileNotFoundError with an actionable message, and prominently document the prerequisite in the docstring and README.

Acceptance criteria

  • Calling analyze_single_patent for a patent whose PDF does not exist either downloads it automatically (Option A) or raises a descriptive error (Option B).
  • A unit test covers both the happy path and the missing-file case.
  • No regression in existing batch analysis tests.

References

Roadmap: P2 Backend — analyze_single_patent assumes local file path.

## Background `analyze_single_patent` constructs a path `patents/{patent_id}.pdf` and reads the file from disk, but does not download the PDF first. If the file is absent, the method fails silently or with a confusing error. ## What to do **Option A (preferred):** Integrate the download step — before reading the file, check if it exists and, if not, download it via the existing download utility. **Option B (acceptable short-term):** Raise a clear `FileNotFoundError` with an actionable message, and prominently document the prerequisite in the docstring and README. ## Acceptance criteria - Calling `analyze_single_patent` for a patent whose PDF does not exist either downloads it automatically (Option A) or raises a descriptive error (Option B). - A unit test covers both the happy path and the missing-file case. - No regression in existing batch analysis tests. ## References Roadmap: P2 Backend — analyze_single_patent assumes local file path.
AI-Manager added the P2agent-readysmallbug labels 2026-03-30 11:24:02 +00:00
Author
Owner

Already resolved. analyze_single_patent in SPARC/analyzer.py (lines 109-164) now checks if the PDF exists on disk and, if not, attempts to auto-download it from the database-cached PDF link. If no cached link exists, it raises a clear FileNotFoundError with actionable instructions. Both Option A and Option B from the issue are implemented.

Already resolved. `analyze_single_patent` in `SPARC/analyzer.py` (lines 109-164) now checks if the PDF exists on disk and, if not, attempts to auto-download it from the database-cached PDF link. If no cached link exists, it raises a clear `FileNotFoundError` with actionable instructions. Both Option A and Option B from the issue are implemented.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1319