Skip to content

Commit 25b3ddb

Browse files
committed
store label & doc fields as prospective provenance
TODO: fix intent list add/amend tests
1 parent 8edabf8 commit 25b3ddb

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

cwltool/cwlprov/provenance_profile.py

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@
5151
)
5252
from .writablebagfile import create_job, write_bag_file # change this later
5353

54+
# from schema_salad.utils import convert_to_dict
55+
56+
5457
if TYPE_CHECKING:
5558
from .ro import ResearchObject
5659

60+
_attributes_type = Dict[str | Identifier, Any]
61+
5762

5863
def copy_job_order(job: Union[Process, JobsType], job_order_object: CWLObjectType) -> CWLObjectType:
5964
"""Create copy of job object for provenance."""
@@ -235,13 +240,13 @@ def evaluate(
235240
"""Evaluate the nature of job."""
236241
if not hasattr(process, "steps"):
237242
# record provenance of independent commandline tool executions
238-
self.prospective_prov(job)
243+
self.prospective_prov(job, process)
239244
customised_job = copy_job_order(job, job_order_object)
240245
self.used_artefacts(customised_job, self.workflow_run_uri)
241246
create_job(research_obj, customised_job)
242247
elif hasattr(job, "workflow"):
243248
# record provenance of workflow executions
244-
self.prospective_prov(job)
249+
self.prospective_prov(job, process)
245250
customised_job = copy_job_order(job, job_order_object)
246251
self.used_artefacts(customised_job, self.workflow_run_uri)
247252
# if CWLPROV['prov'].uri in job_order_object: # maybe move this to another place
@@ -734,35 +739,38 @@ def generate_output_prov(
734739
entity, process_run_id, timestamp, None, {"prov:role": role}
735740
)
736741

737-
def prospective_prov(self, job: JobsType) -> None:
742+
def prospective_prov(self, job: JobsType, process: Process) -> None:
738743
"""Create prospective prov recording as wfdesc prov:Plan."""
744+
prov_items: _attributes_type = {
745+
PROV_TYPE: WFDESC["Workflow"] if isinstance(job, WorkflowJob) else WFDESC["Process"],
746+
"prov:type": PROV["Plan"],
747+
"prov:label": "Prospective provenance",
748+
}
749+
if "doc" in process.tool:
750+
prov_items["schema:description"] = process.tool["doc"]
751+
if "label" in process.tool:
752+
prov_items["schema:name"] = process.tool["label"]
753+
# # TypeError: unhashable type: 'list'
754+
# if "intent" in process.tool:
755+
# prov_items["schema:featureList"] = convert_to_dict(process.tool["intent"])
756+
self.document.entity("wf:main", prov_items)
739757
if not isinstance(job, WorkflowJob):
740-
# direct command line tool execution
741-
self.document.entity(
742-
"wf:main",
743-
{
744-
PROV_TYPE: WFDESC["Process"],
745-
"prov:type": PROV["Plan"],
746-
"prov:label": "Prospective provenance",
747-
},
748-
)
749758
return
750759

751-
self.document.entity(
752-
"wf:main",
753-
{
754-
PROV_TYPE: WFDESC["Workflow"],
755-
"prov:type": PROV["Plan"],
756-
"prov:label": "Prospective provenance",
757-
},
758-
)
759-
760760
for step in job.steps:
761761
stepnametemp = "wf:main/" + str(step.name)[5:]
762762
stepname = urllib.parse.quote(stepnametemp, safe=":/,#")
763+
provstep_items: _attributes_type = {
764+
PROV_TYPE: WFDESC["Process"],
765+
"prov:type": PROV["Plan"],
766+
}
767+
if "doc" in step.tool:
768+
provstep_items["schema:description"] = step.tool["doc"]
769+
if "label" in step.tool:
770+
provstep_items["schema:name"] = step.tool["label"]
763771
provstep = self.document.entity(
764772
stepname,
765-
{PROV_TYPE: WFDESC["Process"], "prov:type": PROV["Plan"]},
773+
provstep_items,
766774
)
767775
self.document.entity(
768776
"wf:main",

0 commit comments

Comments
 (0)