fix(ocr): sync workflow steps with process_with_ocr replacing legacy azure step

- Update _compute_processing_flow to recognize process_with_ocr as the OCR
  stage and remap legacy process_with_azure_document_intelligence log entries
  for backward compatibility
- Normalize legacy OCR step name in _compute_step_summary log fallback
- Add process_with_ocr to REAL_MAIN_STEPS/REAL_STEPS in step_manager,
  file_status, and file_queries (keeping legacy name for old DB entries)
- Update retry logic in api/files.py to retry failed OCR via process_with_ocr
  (handles both step names as aliases)
- Fix process_document.py to log process_with_ocr as skipped (not azure step)
  for the local text extraction path

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-24 22:22:06 +00:00
parent f937fd4971
commit 37a3f7aae7
6 changed files with 34 additions and 22 deletions
+11 -4
View File
@@ -222,11 +222,11 @@ def _compute_processing_flow(logs):
"create_file_record": {"label": "Create File Record", "next": ["check_text"]},
"check_text": {
"label": "Check Embedded Text",
"next": ["extract_text", "process_with_azure_document_intelligence"],
"next": ["extract_text", "process_with_ocr"],
},
"extract_text": {"label": "Extract Text (Local)", "next": ["extract_metadata_with_gpt"]},
"process_with_azure_document_intelligence": {
"label": "OCR Processing (Azure)",
"process_with_ocr": {
"label": "OCR Processing",
"next": ["extract_metadata_with_gpt"],
},
"extract_metadata_with_gpt": {"label": "Extract Metadata (GPT)", "next": ["embed_metadata_into_pdf"]},
@@ -285,6 +285,9 @@ def _compute_processing_flow(logs):
{"status": log.status, "message": log.message, "timestamp": log.timestamp, "task_id": log.task_id}
)
else:
# Normalize legacy OCR step name for backward compatibility with old log entries
if step_name == "process_with_azure_document_intelligence":
step_name = "process_with_ocr"
# Regular processing step
if step_name not in step_map:
step_map[step_name] = []
@@ -366,7 +369,7 @@ def _compute_step_summary(logs):
"create_file_record",
"check_text",
"extract_text",
"process_with_azure_document_intelligence",
"process_with_ocr",
"extract_metadata_with_gpt",
"embed_metadata_into_pdf",
"finalize_document_storage",
@@ -391,6 +394,10 @@ def _compute_step_summary(logs):
if status == "pending":
status = "queued"
# Normalize legacy OCR step name for backward compatibility
if step_name == "process_with_azure_document_intelligence":
step_name = "process_with_ocr"
# Check if it's an upload task
is_upload = any(step_name.startswith(prefix) for prefix in upload_prefixes)