Skip to content

Commit 00cf177

Browse files
committed
basic test & fix typing
1 parent 6909002 commit 00cf177

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

cwltool/provenance_profile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def record_process_end(
312312
self.document.wasEndedBy(process_run_id, None, self.workflow_run_uri, when)
313313

314314
def _add_nested_annotations(
315-
self, annotation_key, annotation_value, e: ProvEntity
315+
self, annotation_key: str, annotation_value: Any, e: ProvEntity
316316
) -> ProvEntity:
317317
"""Propagate input data annotations to provenance."""
318318
# Change https:// into http:// first
@@ -404,7 +404,7 @@ def declare_file(self, value: CWLObjectType) -> Tuple[ProvEntity, ProvEntity, st
404404
# Transfer SCHEMA annotations to provenance
405405
for s in schema_annotations:
406406
if "additionalType" in s:
407-
additional_type = schema_annotations[s].split(sep="/")[
407+
additional_type = cast(str, schema_annotations[s]).split(sep="/")[
408408
-1
409409
] # find better method?
410410
file_entity.add_attributes({PROV_TYPE: SCHEMA[additional_type]})
@@ -533,7 +533,7 @@ def declare_directory(self, value: CWLObjectType) -> ProvEntity:
533533
# Transfer SCHEMA annotations to provenance
534534
for s in schema_annotations:
535535
if "additionalType" in s:
536-
additional_type = schema_annotations[s].split(sep="/")[
536+
additional_type = cast(str, schema_annotations[s]).split(sep="/")[
537537
-1
538538
] # find better method?
539539
coll.add_attributes({PROV_TYPE: SCHEMA[additional_type]})

tests/test_provenance.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,28 @@ def test_revsort_workflow(tmp_path: Path) -> None:
8181
check_provenance(folder)
8282

8383

84+
@needs_docker
85+
def test_revsort_label_annotations(tmp_path: Path) -> None:
86+
"""Affirm that EDAM file formats in the input object make it into CWLProv."""
87+
base_path = cwltool(
88+
tmp_path,
89+
get_data("tests/wf/revsort.cwl"),
90+
get_data("tests/wf/revsort-job.json"),
91+
)
92+
prov_file = base_path / "metadata" / "provenance" / "primary.cwlprov.nt"
93+
arcp_root = find_arcp(base_path)
94+
g = Graph()
95+
with open(prov_file, "rb") as f:
96+
g.parse(file=f, format="nt", publicID=arcp_root)
97+
mime_having_objects = list(g.subjects(SCHEMA.encodingFormat))
98+
assert len(mime_having_objects) == 2
99+
for obj in mime_having_objects:
100+
assert (
101+
cast(Literal, list(g.objects(obj, SCHEMA.encodingFormat))[0]).value
102+
== "https://www.iana.org/assignments/media-types/text/plain"
103+
)
104+
105+
84106
@needs_docker
85107
def test_nested_workflow(tmp_path: Path) -> None:
86108
check_provenance(cwltool(tmp_path, get_data("tests/wf/nested.cwl")), nested=True)

0 commit comments

Comments
 (0)