Skip to content

Commit 15f90b6

Browse files
author
Bob Strahan
committed
fix: remove redundant status update in extraction function and improve section document handling in process results
1 parent fcd9414 commit 15f90b6

File tree

2 files changed

+6
-8
lines changed
  • patterns/pattern-3/src

2 files changed

+6
-8
lines changed

patterns/pattern-3/src/extraction_function/index.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def handler(event, context):
2525
Process a single section of a document for information extraction
2626
"""
2727
logger.info(f"Event: {json.dumps(event)}")
28+
2829
# Load configuration
2930
config = get_config()
3031
logger.info(f"Config: {json.dumps(config)}")
@@ -75,10 +76,6 @@ def handler(event, context):
7576
if section_document.status == Status.FAILED:
7677
error_message = f"Extraction failed for document {section_document.id}, section {section_id}"
7778
logger.error(error_message)
78-
# Update status in AppSync before raising exception
79-
full_document.status = Status.FAILED
80-
full_document.errors.append(error_message)
81-
appsync_service.update_document(full_document)
8279
raise Exception(error_message)
8380

8481
# Return section extraction result with the document

patterns/pattern-3/src/processresults_function/index.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ def handler(event, context):
4444

4545
# Combine all section results
4646
for result in extraction_results:
47-
# Get section document from extraction result
48-
if "document" in result:
47+
# Get section document from assessment result (if populated)
48+
# or extraction result if assessment is disabled
49+
section_document = Document.from_dict(result.get("AssessmentResult", {}).get("document", {}))
50+
if not section_document:
4951
section_document = Document.from_dict(result.get("document", {}))
50-
section_id = result.get("section_id")
51-
52+
if section_document:
5253
# Add section to document if present
5354
if section_document.sections:
5455
section = section_document.sections[0]

0 commit comments

Comments
 (0)