Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dsc/reports/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class CreateReport(Report):

@property
def subject(self) -> str:
return f"DSC Create Batch Results - {self.workflow_name}, batch='{self.batch_id}'"
return f"[{CONFIG.workspace}] DSC Create Batch Results - {self.workflow_name}, batch='{self.batch_id}'" # noqa: E501

@property
def summary_template(self) -> Template:
Expand Down Expand Up @@ -196,7 +196,7 @@ def create_errors_csv(self) -> StringIO | None:
class SubmitReport(Report):
@property
def subject(self) -> str:
return f"DSC Submit Results - {self.workflow_name}, batch='{self.batch_id}'"
return f"[{CONFIG.workspace}] DSC Submit Results - {self.workflow_name}, batch='{self.batch_id}'" # noqa: E501

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart addition!


@property
def summary_template(self) -> Template:
Expand Down
10 changes: 8 additions & 2 deletions dsc/workflows/digitized_theses/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,10 @@ def submit_items(self, collection_handle: str | None = None) -> list:
try:
# get item metadata
item_metadata = self._get_transformed_metadata(
item_identifier=item_submission.item_identifier,
source_metadata_file=manifest[item_submission.item_identifier][
"metadata_file"
]
],
)

# prepare submission assets
Expand Down Expand Up @@ -620,7 +621,9 @@ def _load_batch_manifest(self) -> dict:

return manifest

def _get_transformed_metadata(self, source_metadata_file: str) -> dict:
def _get_transformed_metadata(
self, item_identifier: str, source_metadata_file: str
) -> dict:
"""Get transformed metadata for an item submission.

This method expects a filepath to an Alma MARC XML file.
Expand All @@ -638,6 +641,9 @@ def _get_transformed_metadata(self, source_metadata_file: str) -> dict:

transformed_metadata = self.metadata_transformer.transform(source_metadata)

# set dc.identifier.oclc to item identifier
transformed_metadata["dc.identifier.oclc"] = item_identifier

# if replacement thesis, include additional dc.description.provenance entry
if "replacement-theses" in source_metadata_file:
replacement_message = f"The thesis import has been updated on {self.run_date.strftime('%Y-%m-%dT%H:%M:%SZ')}" # noqa: E501
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies = [
"lxml>=6.0.2",
"pandas>=2.3.3",
"pynamodb>=6.1.0",
"requests>=2.33.0",
"sentry-sdk>=2.50.0",
"smart_open",
]
Expand Down
4 changes: 3 additions & 1 deletion tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def test_report_init_success():
assert create_report.workflow_name == "test"
assert create_report.batch_id == "batch-aaa"
assert create_report.report_date == "20250101T090000Z"
assert create_report.subject == ("DSC Create Batch Results - test, batch='batch-aaa'")
assert create_report.subject == (
"[test] DSC Create Batch Results - test, batch='batch-aaa'"
)


def test_report_get_item_submissions(mock_item_submission_db_with_records):
Expand Down
4 changes: 3 additions & 1 deletion tests/workflows/digitized_theses/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,11 @@ def test_workflow_load_batch_manifest(mock_s3_digitized_theses_dsc):
def test_workflow_get_transformed_metadata(mock_s3_digitized_theses_dsc):
workflow = DigitizedTheses(batch_id="batch-aaa")
item_metadata = workflow._get_transformed_metadata(
source_metadata_file="tests/fixtures/digitized-theses/batch-aaa/replacement-theses/05588126/05588126.xml"
item_identifier="05588126",
source_metadata_file="tests/fixtures/digitized-theses/batch-aaa/replacement-theses/05588126/05588126.xml",
)

assert item_metadata["dc.identifier.oclc"] == "05588126"
assert item_metadata["dc.title"] == [
"Global solvability of invariant differential operators."
]
Expand Down
Loading
Loading