diff --git a/pydra/engine/audit.py b/pydra/engine/audit.py index 7648843c33..2309138ae0 100644 --- a/pydra/engine/audit.py +++ b/pydra/engine/audit.py @@ -66,8 +66,7 @@ def start_audit(self, odir): start_message = { "@id": self.aid, "@type": "job", - "startedAtTime": now(), - "executedBy": user_id, + "StartedAtTime": now(), } os.chdir(self.odir) @@ -88,7 +87,7 @@ def monitor(self): { "@id": self.mid, "@type": "monitor", - "startedAtTime": now(), + "StartedAtTime": now(), "wasStartedBy": self.aid, }, AuditFlag.PROV, @@ -103,7 +102,7 @@ def finalize_audit(self, result): result.runtime = gather_runtime_info(self.resource_monitor.fname) if self.audit_check(AuditFlag.PROV): self.audit_message( - {"@id": self.mid, "endedAtTime": now(), "wasEndedBy": self.aid}, + {"@id": self.mid, "EndedAtTime": now(), "wasEndedBy": self.aid}, AuditFlag.PROV, ) # audit resources/runtime information @@ -113,14 +112,14 @@ def finalize_audit(self, result): **{ "@id": self.eid, "@type": "runtime", - "prov:wasGeneratedBy": self.aid, + "GeneratedBy": self.aid, } ) self.audit_message(entity, AuditFlag.PROV) self.audit_message( { "@type": "prov:Generation", - "entity_generated": self.eid, + "runtime": self.eid, "hadActivity": self.mid, }, AuditFlag.PROV, @@ -129,7 +128,7 @@ def finalize_audit(self, result): if self.audit_check(AuditFlag.PROV): # audit outputs self.audit_message( - {"@id": self.aid, "endedAtTime": now(), "errored": result.errored}, + {"@id": self.aid, "EndedAtTime": now(), "errored": result.errored}, AuditFlag.PROV, ) @@ -188,8 +187,10 @@ def audit_task(self, job: "Job"): label = job.name + # YC: currently command only support shellcommand task + # we can make function itself a command too command = job.task.cmdline if hasattr(job.task, "executable") else None - attr_list = task_fields(job.task) + attr_list = attr_fields(task.inputs) for attrs in attr_list: input_name = attrs.name value = job.inputs[input_name] @@ -231,7 +232,14 @@ def audit_task(self, job: "Job"): "Label": label, "Command": command, "StartedAtTime": now(), - "AssociatedWith": version_cmd, + "AssociatedWith": { + "@id": self.aid, + # YC: need to add Label, which should be + # the software name in a shellcommand task + # the function's package in a function task + # else be python + "Version": version_cmd, + }, } self.audit_message(start_message, AuditFlag.PROV) diff --git a/pydra/schema/context.jsonld b/pydra/schema/context.jsonld index 7e01b96ccd..9d6afab5b5 100644 --- a/pydra/schema/context.jsonld +++ b/pydra/schema/context.jsonld @@ -8,7 +8,7 @@ "@container": "@type" } }, - "https://raw.githubusercontent.com/openprov/prov-jsonld/69964ed16818f78dc5f71bdf97add026288291d4/context.json", + "https://raw.githubusercontent.com/bids-standard/BEP028_BIDSprov/master/context.json", { "pydra": "http://s.pydra.org/", "uid": "pydra:id/", @@ -24,10 +24,6 @@ "@id": "pydra:runtimeInformation", "@type": "@vocab" }, - "prov:wasGeneratedBy": { - "@id": "prov:wasGeneratedBy", - "@type": "@vocab" - }, "rss_peak_gb": { "@id": "pydra:rss_peak_gb", "@type": "xsd:float" @@ -40,6 +36,15 @@ "@id": "pydra:cpu_peak_percent", "@type": "xsd:float" }, + "wasStartedBy": { + "@id": "uid" + }, + "wasEndedBy": { + "@id": "uid" + }, + "hadActivity": { + "@id": "uid" + }, "errored": { "@id": "pydra:errored", "@type": "xsd:boolean"