Skip to content

Commit

Permalink
Update report_lines > report_data
Browse files Browse the repository at this point in the history
  • Loading branch information
ehanson8 committed Jan 22, 2025
1 parent a0fd921 commit 8e05358
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions dsc/workflows/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(
self.s3_bucket = s3_bucket
if output_queue:
self.output_queue = output_queue
self.report_lines: list[str] = []
self.report_data: list[str] = []

@property
def batch_path(self) -> str:
Expand Down Expand Up @@ -356,7 +356,7 @@ def process_results(self) -> None:
items = self.process_sqs_queue()
self.workflow_specific_processing(items)

def process_sqs_queue(self) -> list[tuple[str, dict[str, Any]]]:
def process_sqs_queue(self) -> list[tuple[str, dict]]:
"""Process messages in DSS ouput queue to extract necessary data.
May be overridden by workflow subclasses.
Expand All @@ -374,11 +374,11 @@ def process_sqs_queue(self) -> list[tuple[str, dict[str, Any]]]:
)
items.append((item_identifier, message_body))
logger.debug(item_identifier, message_body)
self.report_lines.append(f"{item_identifier}: {message_body}")
self.report_data.append(f"{item_identifier}: {message_body}")
except Exception:
error_message = f"Error while processing SQS message: {sqs_message}"
logger.exception(error_message)
self.report_lines.append(error_message)
self.report_data.append(error_message)
continue
logger.debug(f"Messages received and deleted from '{self.output_queue}'")
return items
Expand All @@ -392,7 +392,7 @@ def workflow_specific_processing(self, items: list[tuple]) -> None:
def report_results(self) -> None:
"""Send report to stakeholders as an email via SES."""
date = datetime.datetime.now(tz=datetime.UTC).strftime("%Y-%m-%d %H:%M:%S")
report = "\n".join(self.report_lines)
report = "\n".join(self.report_data)
logger.info(report)
ses_client = SESClient(region=CONFIG.aws_region_name)
ses_client.create_and_send_email(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def test_base_workflow_report_results_success(
mocked_ses,
):
caplog.set_level("DEBUG")
base_workflow_instance.report_lines = [
base_workflow_instance.report_data = [
"10.1002/term.3131: {'ResultType': 'success', 'ItemHandle': '1721.1/131022', "
"'lastModified': 'Thu Sep 09 17:56:39 UTC 2021', 'Bitstreams': "
"[{'BitstreamName': '10.1002-term.3131.pdf', 'BitstreamUUID': 'a1b2c3d4e5', "
Expand Down

0 comments on commit 8e05358

Please sign in to comment.