Skip to content

Commit

Permalink
Merge pull request #339 from microbiomedata/338-workflow-automation-d…
Browse files Browse the repository at this point in the history
…ata-objects-are-missing-file_size_bytes

338 workflow automation data objects are missing file size bytes
  • Loading branch information
mbthornton-lbl authored Jan 6, 2025
2 parents 07d1ce2 + 0a9743b commit 9cf59cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions nmdc_automation/workflow_automation/wfutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ def make_data_objects(self, output_dir: Union[str, Path] = None) -> List[DataObj


md5_sum = _md5(output_file_path)
file_size_bytes = output_file_path.stat().st_size
file_url = f"{self.url_root}/{self.was_informed_by}/{self.workflow_execution_id}/{output_file_path.name}"

# copy the file to the output directory if provided
Expand All @@ -542,6 +543,7 @@ def make_data_objects(self, output_dir: Union[str, Path] = None) -> List[DataObj
data_object = DataObject(
id=output_spec["id"], name=output_file_path.name, type="nmdc:DataObject", url=file_url,
data_object_type=output_spec["data_object_type"], md5_checksum=md5_sum,
file_size_bytes=file_size_bytes,
description=output_spec["description"].replace('{id}', self.workflow_execution_id),
was_generated_by=self.workflow_execution_id, )

Expand Down
4 changes: 2 additions & 2 deletions tests/test_wfutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_workflow_execution_record_from_workflow_job(site_config, fixtures_dir,
assert wfe.ended_at_time


def test_make_data_objects_substutes_workflow_id(site_config, fixtures_dir, tmp_path):
def test_make_data_objects_includes_workflow_execution_id_and_file_size(site_config, fixtures_dir, tmp_path):
job_metadata = json.load(open(fixtures_dir / "mags_job_metadata.json"))
workflow_state = json.load(open(fixtures_dir / "mags_workflow_state.json"))
job = WorkflowJob(site_config, workflow_state, job_metadata)
Expand All @@ -329,7 +329,7 @@ def test_make_data_objects_substutes_workflow_id(site_config, fixtures_dir, tmp_
for data_object in data_objects:
assert isinstance(data_object, DataObject)
assert job.workflow_execution_id in data_object.description

assert data_object.file_size_bytes



Expand Down

0 comments on commit 9cf59cb

Please sign in to comment.