forked from 0xWheatyz/SPARC
Integrate PDF download step into analyze_single_patent or document the prerequisite clearly #1276
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
analyze_single_patentconstructspatents/{patent_id}.pdfand reads it from disk, but never downloads the PDF first. Callers that do not separately download the file get an unhandled file-not-found error.Roadmap reference: P2 - Backend: analyze_single_patent assumes local file path
What to do
Choose one approach:
Option A (preferred): Before reading the file, check if it exists; if not, call the existing PDF download helper to fetch it into the
patents/directory, then proceed.Option B: Raise a clear
ValueError/ HTTP 400 with a message like "PDF not found for patent {id}; call /patents/{id}/download first" and add that prerequisite to the API docs.Acceptance criteria
analyze_single_patentfor a patent with no local PDF does not raise an unhandledFileNotFoundError.Triage: Already Implemented
PDF auto-download is integrated into
analyze_single_patentonmain:SPARC/analyzer.pyanalyze_single_patent()checks if the PDF exists on disk, and if not, looks up the cached download link in the database and downloads it automatically.FileNotFoundErrorwith an actionable message.Closing as completed.