From 6b3a55698faa854e9c0b1fe51d50518084e488ea Mon Sep 17 00:00:00 2001 From: Yibei Chen Date: Fri, 12 Apr 2024 18:47:05 +0000 Subject: [PATCH 1/3] update context using bep028 context --- pydra/schema/context.jsonld | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pydra/schema/context.jsonld b/pydra/schema/context.jsonld index 7e01b96ccd..d1216bc571 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" From e00a61ad75c51161373dbae8691e32963ea9757d Mon Sep 17 00:00:00 2001 From: Yibei Chen Date: Fri, 12 Apr 2024 20:05:36 +0000 Subject: [PATCH 2/3] add customized fields and fix typos --- pydra/engine/audit.py | 25 +++++++++++++++++-------- pydra/schema/context.jsonld | 9 +++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/pydra/engine/audit.py b/pydra/engine/audit.py index 7397fad6e6..f8b1d83a89 100644 --- a/pydra/engine/audit.py +++ b/pydra/engine/audit.py @@ -62,8 +62,7 @@ def start_audit(self, odir): start_message = { "@id": self.aid, "@type": "task", - "startedAtTime": now(), - "executedBy": user_id, + "StartedAtTime": now(), } os.chdir(self.odir) @@ -84,7 +83,7 @@ def monitor(self): { "@id": self.mid, "@type": "monitor", - "startedAtTime": now(), + "StartedAtTime": now(), "wasStartedBy": self.aid, }, AuditFlag.PROV, @@ -97,7 +96,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 @@ -107,14 +106,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, @@ -123,7 +122,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, ) @@ -181,6 +180,8 @@ def audit_task(self, task): label = task.name + # YC: currently command only support shellcommand task + # we can make function itself a command too command = task.cmdline if hasattr(task.inputs, "executable") else None attr_list = attr_fields(task.inputs) for attrs in attr_list: @@ -224,7 +225,15 @@ def audit_task(self, task): "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 d1216bc571..9d6afab5b5 100644 --- a/pydra/schema/context.jsonld +++ b/pydra/schema/context.jsonld @@ -36,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" From 2c0f6aa2fcfe53f2b99c8b8dca5854a632cdca9d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 21:12:36 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pydra/engine/audit.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pydra/engine/audit.py b/pydra/engine/audit.py index f8b1d83a89..ac86529e4d 100644 --- a/pydra/engine/audit.py +++ b/pydra/engine/audit.py @@ -225,15 +225,14 @@ def audit_task(self, task): "Label": label, "Command": command, "StartedAtTime": now(), - "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 - }, + "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)