Skip to content

Commit 99fc196

Browse files
committed
Propagate schema.org annotations to provenance
1 parent 93f091a commit 99fc196

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

cwltool/provenance_profile.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,23 @@ def declare_file(self, value: CWLObjectType) -> Tuple[ProvEntity, ProvEntity, st
350350
file_entity.add_attributes({CWLPROV["nameext"]: value["nameext"]})
351351
self.document.specializationOf(file_entity, entity)
352352

353+
def recursive_function(dataset, e: ProvEntity) -> ProvEntity:
354+
for annotation in dataset:
355+
if isinstance(dataset[annotation], (str, bool, int, float)): # check if these are all allowed types
356+
e.add_attributes({annotation: dataset[annotation]})
357+
else:
358+
nested_id = uuid.uuid4().urn
359+
# e.add_attributes({annotation: nested_id})
360+
nested_entity = self.document.entity(nested_id)
361+
e.add_attributes({annotation: nested_entity.identifier})
362+
nested_entity = recursive_function(dataset[annotation], nested_entity)
363+
return e
364+
353365
# Transfer input data annotations to provenance:
354-
if "label" in value:
355-
file_entity.add_attributes({PROV_LABEL: value["label"]})
366+
if SCHEMA["Dataset"].uri in value:
367+
entity.add_attributes( {PROV_TYPE: SCHEMA["Dataset"]})
368+
entity = recursive_function(value[SCHEMA["Dataset"].uri], entity)
369+
356370

357371
# Check for secondaries
358372
for sec in cast(

0 commit comments

Comments
 (0)