@@ -78,7 +78,6 @@ def copy_job_order(
78
78
return customised_job
79
79
80
80
81
-
82
81
class ProvenanceProfile :
83
82
"""
84
83
Provenance profile.
@@ -261,11 +260,9 @@ def evaluate(
261
260
# # add nested annotations
262
261
# # how much of this can we reuse from _add_nested_annotations?
263
262
# # how do we identify the correct file to write to? self.workflow_run_uri?
264
- # #
263
+ # #
265
264
# pass
266
265
267
-
268
-
269
266
def record_process_start (
270
267
self , process : Process , job : JobsType , process_run_id : Optional [str ] = None
271
268
) -> Optional [str ]:
@@ -314,14 +311,16 @@ def record_process_end(
314
311
self .generate_output_prov (outputs , process_run_id , process_name )
315
312
self .document .wasEndedBy (process_run_id , None , self .workflow_run_uri , when )
316
313
317
- def _add_nested_annotations (self , annotation_key , annotation_value , e : ProvEntity ) -> ProvEntity :
314
+ def _add_nested_annotations (
315
+ self , annotation_key , annotation_value , e : ProvEntity
316
+ ) -> ProvEntity :
318
317
"""Propagate input data annotations to provenance."""
319
318
# Change https:// into http:// first
320
- schema2_uri = "https://schema.org/"
319
+ schema2_uri = "https://schema.org/"
321
320
if schema2_uri in annotation_key :
322
- annotation_key = SCHEMA [annotation_key .replace (schema2_uri , '' )].uri
323
-
324
- if not isinstance (annotation_value , (MutableSequence , MutableMapping )):
321
+ annotation_key = SCHEMA [annotation_key .replace (schema2_uri , "" )].uri
322
+
323
+ if not isinstance (annotation_value , (MutableSequence , MutableMapping )):
325
324
e .add_attributes ({annotation_key : str (annotation_value )})
326
325
elif isinstance (annotation_value , MutableSequence ):
327
326
for item_value in annotation_value :
@@ -331,8 +330,10 @@ def _add_nested_annotations(self, annotation_key, annotation_value, e: ProvEntit
331
330
nested_entity = self .document .entity (nested_id )
332
331
e .add_attributes ({annotation_key : nested_entity .identifier })
333
332
for nested_key in annotation_value :
334
- nested_value = annotation_value [nested_key ]
335
- nested_entity = self ._add_nested_annotations (nested_key , nested_value , nested_entity )
333
+ nested_value = annotation_value [nested_key ]
334
+ nested_entity = self ._add_nested_annotations (
335
+ nested_key , nested_value , nested_entity
336
+ )
336
337
return e
337
338
338
339
def declare_file (self , value : CWLObjectType ) -> Tuple [ProvEntity , ProvEntity , str ]:
@@ -396,15 +397,21 @@ def declare_file(self, value: CWLObjectType) -> Tuple[ProvEntity, ProvEntity, st
396
397
self .document .specializationOf (file_entity , entity )
397
398
398
399
# Identify all schema annotations
399
- schema_annotations = dict ([(v , value [v ]) for v in value .keys () if 'schema.org' in v ])
400
+ schema_annotations = dict (
401
+ [(v , value [v ]) for v in value .keys () if "schema.org" in v ]
402
+ )
400
403
401
404
# Transfer SCHEMA annotations to provenance
402
405
for s in schema_annotations :
403
406
if "additionalType" in s :
404
- additional_type = schema_annotations [s ].split (sep = '/' )[- 1 ] # find better method?
405
- file_entity .add_attributes ( {PROV_TYPE : SCHEMA [additional_type ]})
406
- else :
407
- file_entity = self ._add_nested_annotations (s , schema_annotations [s ], file_entity )
407
+ additional_type = schema_annotations [s ].split (sep = "/" )[
408
+ - 1
409
+ ] # find better method?
410
+ file_entity .add_attributes ({PROV_TYPE : SCHEMA [additional_type ]})
411
+ else :
412
+ file_entity = self ._add_nested_annotations (
413
+ s , schema_annotations [s ], file_entity
414
+ )
408
415
409
416
# Transfer format annotations to provenance:
410
417
if "format" in value :
@@ -517,18 +524,22 @@ def declare_directory(self, value: CWLObjectType) -> ProvEntity:
517
524
518
525
coll .add_attributes (coll_attribs )
519
526
coll_b .add_attributes (coll_b_attribs )
520
-
527
+
521
528
# Identify all schema annotations
522
- schema_annotations = dict ([(v , value [v ]) for v in value .keys () if 'schema.org' in v ])
529
+ schema_annotations = dict (
530
+ [(v , value [v ]) for v in value .keys () if "schema.org" in v ]
531
+ )
523
532
524
533
# Transfer SCHEMA annotations to provenance
525
534
for s in schema_annotations :
526
535
if "additionalType" in s :
527
- additional_type = schema_annotations [s ].split (sep = '/' )[- 1 ] # find better method?
528
- coll .add_attributes ( {PROV_TYPE : SCHEMA [additional_type ]})
536
+ additional_type = schema_annotations [s ].split (sep = "/" )[
537
+ - 1
538
+ ] # find better method?
539
+ coll .add_attributes ({PROV_TYPE : SCHEMA [additional_type ]})
529
540
elif "hasPart" not in s :
530
541
coll = self ._add_nested_annotations (s , schema_annotations [s ], coll )
531
-
542
+
532
543
# Also Save ORE Folder as annotation metadata
533
544
ore_doc = ProvDocument ()
534
545
ore_doc .add_namespace (ORE )
0 commit comments