Skip to content

Commit 4c9038e

Browse files
authored
Merge pull request #862 from common-workflow-language/prov-nested-wf-fixes
Provenance: PROV links for nested workflows
2 parents 55f0dd9 + 761e91c commit 4c9038e

29 files changed

+882
-729
lines changed

cwltool/executors.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def execute(self,
110110
process.parent_wf.document.wasEndedBy(
111111
process.parent_wf.workflow_run_uri, None, process.parent_wf.engine_uuid,
112112
datetime.datetime.now())
113-
process.parent_wf.finalize_prov_profile(name)
113+
process.parent_wf.finalize_prov_profile(name=None)
114114
return (self.final_output[0], self.final_status[0])
115115
return (None, "permanentFail")
116116

@@ -130,10 +130,12 @@ def run_jobs(self,
130130
# define provenance profile for single commandline tool
131131
if not isinstance(process, Workflow) \
132132
and runtime_context.research_obj is not None:
133-
orcid = runtime_context.orcid
134-
full_name = runtime_context.cwl_full_name
135133
process.provenance_object = CreateProvProfile(
136-
runtime_context.research_obj, orcid, full_name)
134+
runtime_context.research_obj,
135+
full_name=runtime_context.cwl_full_name,
136+
orcid=runtime_context.orcid,
137+
# single tool execution, so RO UUID = wf UUID = tool UUID
138+
run_uuid=runtime_context.research_obj.ro_uuid)
137139
process.parent_wf = process.provenance_object
138140
jobiter = process.job(job_order_object, self.output_callback,
139141
runtime_context)

cwltool/job.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ def _execute(self,
226226
if self.joborder and runtimeContext.research_obj:
227227
job_order = self.joborder
228228
assert runtimeContext.prov_obj
229+
assert runtimeContext.process_run_id
229230
runtimeContext.prov_obj.used_artefacts(
230231
job_order, runtimeContext.process_run_id, str(self.name))
231232
outputs = {} # type: Dict[Text,Text]

cwltool/provenance.py

Lines changed: 379 additions & 125 deletions
Large diffs are not rendered by default.

cwltool/workflow.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import six
1919
from six import string_types
2020
from six.moves import range
21+
from uuid import UUID # pylint: disable=unused-import
2122

2223
from . import command_line_tool, expression
2324
from .builder import CONTENT_LIMIT
@@ -255,7 +256,10 @@ def do_output_callback(self, final_output_callback):
255256
self.prov_obj.document.wasEndedBy(
256257
self.prov_obj.workflow_run_uri, None, self.prov_obj.engine_uuid,
257258
datetime.datetime.now())
258-
self.prov_obj.finalize_prov_profile(str(self.name))
259+
prov_ids = self.prov_obj.finalize_prov_profile(self.name)
260+
# Tell parent to associate our provenance files with our wf run
261+
self.parent_wf.activity_has_provenance(self.prov_obj.workflow_run_uri, prov_ids)
262+
259263
_logger.info(u"[%s] completed %s", self.name, self.processStatus)
260264
if _logger.isEnabledFor(logging.DEBUG):
261265
_logger.debug(u"[%s] %s", self.name, json_dumps(wo, indent=4))
@@ -499,12 +503,23 @@ def __init__(self,
499503
toolpath_object, loadingContext)
500504
self.provenance_object = None # type: Optional[CreateProvProfile]
501505
if loadingContext.research_obj:
502-
orcid = loadingContext.orcid
503-
full_name = loadingContext.cwl_full_name
506+
run_uuid = None # type: Optional[UUID]
507+
is_master = not(loadingContext.prov_obj) # Not yet set
508+
if is_master:
509+
run_uuid = loadingContext.research_obj.ro_uuid
510+
504511
self.provenance_object = CreateProvProfile(
505-
loadingContext.research_obj, full_name, orcid,
506-
loadingContext.host_provenance, loadingContext.user_provenance)
512+
loadingContext.research_obj,
513+
full_name=loadingContext.cwl_full_name,
514+
orcid=loadingContext.orcid,
515+
host_provenance=loadingContext.host_provenance,
516+
user_provenance=loadingContext.user_provenance,
517+
run_uuid=run_uuid # inherit RO UUID for master wf run
518+
)
519+
# TODO: Is Workflow(..) only called when we are the master workflow?
507520
self.parent_wf = self.provenance_object
521+
522+
# FIXME: Won't this overwrite prov_obj for nested workflows?
508523
loadingContext.prov_obj = self.provenance_object
509524
loadingContext = loadingContext.copy()
510525
loadingContext.requirements = self.requirements

0 commit comments

Comments
 (0)