Skip to content

Commit d0cad13

Browse files
committed
support workflow inputs (incl booleans!)
1 parent 0005b46 commit d0cad13

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

cwltool/provenance.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,10 @@ def copy_job_order(job, job_order_object):
469469
# record provenance of an independent commandline tool execution
470470
self.prospective_prov(job)
471471
customised_job = copy_job_order(job, job_order_object)
472-
relativised_input_object2, reference_locations = \
472+
inputs, reference_locations = \
473473
research_obj.create_job(
474474
customised_job, make_fs_access)
475-
entity = self.declare_artefact(relativised_input_object2)
476-
self.document.used(self.engine_uuid, entity)
475+
self.used_artefacts(inputs, self.workflow_run_uri)
477476
name = ""
478477
if hasattr(job, "name"):
479478
name = str(job.name)
@@ -482,11 +481,10 @@ def copy_job_order(job, job_order_object):
482481
elif hasattr(job, "workflow"): # record provenance for the workflow execution
483482
self.prospective_prov(job)
484483
customised_job = copy_job_order(job, job_order_object)
485-
relativised_input_object2, reference_locations = \
484+
inputs, reference_locations = \
486485
research_obj.create_job(
487486
customised_job, make_fs_access)
488-
entity = self.declare_artefact(relativised_input_object2)
489-
self.document.used(self.engine_uuid, entity)
487+
self.used_artefacts(inputs, self.workflow_run_uri)
490488
else: # in case of commandline tool execution as part of workflow
491489
name = ""
492490
if hasattr(job, "name"):
@@ -538,7 +536,16 @@ def declare_artefact(self, value):
538536
return self.document.entity(CWLPROV["None"],
539537
{ provM.PROV_LABEL: "None" })
540538

541-
if isinstance(value, (str, Text, bytes)):
539+
elif isinstance(value, (bool, int, float)):
540+
# Typically used in job documents for flags
541+
542+
# FIXME: Make consistent hash URIs for these
543+
# that somehow include the type
544+
# (so "1" != 1 != "1.0" != true)
545+
return self.document.entity(uuid.uuid4().urn,
546+
{ provM.PROV_VALUE: value })
547+
548+
elif isinstance(value, (str, Text, bytes)):
542549
if type(value) == bytes:
543550
# Leave as-is (Note: In Python2 this includes strings
544551
# which will be written with system encoding)
@@ -554,7 +561,7 @@ def declare_artefact(self, value):
554561
{provM.PROV_TYPE: WFPROV["Artifact"],
555562
provM.PROV_VALUE: str(value)})
556563

557-
if isinstance(value, dict):
564+
elif isinstance(value, dict):
558565
# Base case - we found a File we need to update
559566
if value.get("class") == "File":
560567
if 'checksum' in value:
@@ -686,15 +693,18 @@ def declare_artefact(self, value):
686693

687694
def used_artefacts(self,
688695
job_order, # type: Dict
689-
process_run_id, # type: Optional[str]
690-
name # type: str
696+
process_run_id, # type: str
697+
name=None # type: Optional[str]
691698
): # type: (...) -> None
692699
'''
693700
adds used() for each data artefact
694701
'''
702+
# FIXME: Use workflow name in packed.cwl, "main" is wrong for nested workflows
703+
base = "main"
704+
if name:
705+
base += "/" + name
695706
for key, value in job_order.items():
696-
# FIXME: Use workflow name in packed.cwl, "main" is wrong for nested workflows
697-
prov_role = self.wf_ns["main/%s/%s" % (name, key)]
707+
prov_role = self.wf_ns["%s/%s" % (base, key)]
698708
entity = self.declare_artefact(value)
699709
self.document.used(
700710
process_run_id, entity,

0 commit comments

Comments
 (0)