Skip to content

Commit 0bf115a

Browse files
author
Bob Strahan
committed
Update evaluation function to pass working bucket and context to serialize_document calls
1 parent cfa78ec commit 0bf115a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/lambda/evaluation_function/index.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def handler(event, context):
157157
"""
158158
actual_document = None
159159
start_time = time.time()
160+
working_bucket = os.environ.get('WORKING_BUCKET')
160161

161162
try:
162163
logger.info(f"Starting evaluation process")
@@ -171,7 +172,7 @@ def handler(event, context):
171172
if not evaluation_enabled:
172173
logger.info("Evaluation is disabled in configuration, skipping evaluation")
173174
# Return document unchanged
174-
return {'document': actual_document.serialize_document()}
175+
return {'document': actual_document.serialize_document(working_bucket, 'evaluation')}
175176

176177
# Set document status to EVALUATING before processing
177178
actual_document.status = Status.EVALUATING
@@ -187,7 +188,7 @@ def handler(event, context):
187188
if not expected_document:
188189
actual_document = update_document_evaluation_status(actual_document, EvaluationStatus.NO_BASELINE)
189190
logger.info("Evaluation skipped - no baseline data available")
190-
return {'document': actual_document.serialize_document()}
191+
return {'document': actual_document.serialize_document(working_bucket, 'evaluation')}
191192

192193
# Create evaluation service
193194
evaluation_service = evaluation.EvaluationService(config=config)
@@ -205,7 +206,7 @@ def handler(event, context):
205206
error_msg = f"Evaluation encountered errors: {evaluated_document.errors}"
206207
logger.error(error_msg)
207208
evaluated_document = update_document_evaluation_status(evaluated_document, EvaluationStatus.FAILED)
208-
return {'document': evaluated_document.serialize_document()}
209+
return {'document': evaluated_document.serialize_document(working_bucket, 'evaluation')}
209210

210211
# Save evaluation results to reporting bucket for analytics using the SaveReportingData Lambda
211212
try:
@@ -236,7 +237,7 @@ def handler(event, context):
236237
logger.info(f"Evaluation process completed successfully in {time.time() - start_time:.2f} seconds")
237238

238239
# Return document in state machine format
239-
return {'document': evaluated_document.serialize_document()}
240+
return {'document': evaluated_document.serialize_document(working_bucket, 'evaluation')}
240241

241242
except Exception as e:
242243
error_msg = f"Error in lambda_handler: {str(e)}"
@@ -246,7 +247,7 @@ def handler(event, context):
246247
if actual_document:
247248
try:
248249
actual_document = update_document_evaluation_status(actual_document, EvaluationStatus.FAILED)
249-
return {'document': actual_document.serialize_document()}
250+
return {'document': actual_document.serialize_document(working_bucket, 'evaluation')}
250251
except Exception as update_error:
251252
logger.error(f"Failed to update evaluation status: {str(update_error)}")
252253

0 commit comments

Comments
 (0)