Skip to content

Commit bf34ca6

Browse files
committed
Directory annotations propagated to provenance
1 parent 79f8b74 commit bf34ca6

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

cwltool/provenance_profile.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def _add_nested_annotations(self, annotation_key, annotation_value, e: ProvEntit
311311
nested_entity = self.document.entity(nested_id)
312312
e.add_attributes({annotation_key: nested_entity.identifier})
313313
for nested_key in annotation_value:
314-
nested_value = annotation_value[nested_key]
314+
nested_value = annotation_value[nested_key]
315315
nested_entity = self._add_nested_annotations(nested_key, nested_value, nested_entity)
316316
return e
317317

@@ -377,7 +377,7 @@ def declare_file(self, value: CWLObjectType) -> Tuple[ProvEntity, ProvEntity, st
377377
if "additionalType" in s:
378378
additional_type = schema_annotations[s].split(sep='/')[-1] # find better method?
379379
entity.add_attributes( {PROV_TYPE: SCHEMA[additional_type]})
380-
else:
380+
else: # add support for CommentedSeq
381381
entity = self._add_nested_annotations(s, schema_annotations[s], entity)
382382

383383
# Transfer format annotations to provenance:
@@ -489,18 +489,17 @@ def declare_directory(self, value: CWLObjectType) -> ProvEntity:
489489

490490
coll.add_attributes(coll_attribs)
491491
coll_b.add_attributes(coll_b_attribs)
492+
493+
# Identify all schema annotations
494+
schema_annotations = dict([(v, value[v]) for v in value.keys() if 'schema.org' in v])
492495

493-
# Propagate input data annotations
494-
if SCHEMA["Dataset"].uri in value:
495-
# coll_annotations = [ (PROV_TYPE, SCHEMA["Dataset"]) ]
496-
coll.add_attributes([ (PROV_TYPE, SCHEMA["Dataset"]) ])
497-
498-
dataset = value[SCHEMA["Dataset"].uri]
499-
500-
for annotation in dataset:
501-
if isinstance(dataset[annotation], (str, bool, int, float)): # check if these are all allowed types
502-
coll.add_attributes({annotation: dataset[annotation]})
503-
496+
# Transfer SCHEMA annotations to provenance
497+
for s in schema_annotations:
498+
if "additionalType" in s:
499+
additional_type = schema_annotations[s].split(sep='/')[-1] # find better method?
500+
coll.add_attributes( {PROV_TYPE: SCHEMA[additional_type]})
501+
elif "hasPart" not in s:
502+
coll = self._add_nested_annotations(s, schema_annotations[s], coll)
504503

505504
# Also Save ORE Folder as annotation metadata
506505
ore_doc = ProvDocument()

0 commit comments

Comments
 (0)