-
Notifications
You must be signed in to change notification settings - Fork 0
Infer WorkflowRun from CreateAction in five-safes SHACL profiles - NEW #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
662cbcd
364a81f
eaa0f9d
4862149
474a297
51efbd6
f0b4879
acd5533
e4a1c23
f1f5c63
eddf1b7
5996412
cfb2729
d576f73
53e5b52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Copyright (c) 2025 eScience Lab, The University of Manchester | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| @prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> . | ||
| @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
| @prefix schema: <http://schema.org/> . | ||
| @prefix sh: <http://www.w3.org/ns/shacl#> . | ||
| @prefix validator: <https://github.com/crs4/rocrate-validator/> . | ||
|
|
||
|
|
||
| ro-crate:FindWorkflowRunAction a sh:NodeShape, validator:HiddenShape; | ||
| sh:order 1 ; | ||
| sh:name "Identify the CreateAction Entity that corresponds to the Workflow run" ; | ||
| sh:description """The Workflow Run is the CreateAction entity that refers to Workflow run. | ||
| This is identified by checking that the CreateAction entity has an `instrument` property | ||
| that references the same entity as the `mainEntity` property of the Root Data Entity.""" ; | ||
| sh:target [ | ||
| a sh:SPARQLTarget ; | ||
| sh:prefixes ro-crate:sparqlPrefixes ; | ||
| sh:select """ | ||
| SELECT ?this | ||
| WHERE { | ||
| ?this a schema:CreateAction ; | ||
| schema:instrument ?instrument . | ||
| ?root a ro-crate:RootDataEntity ; | ||
| schema:mainEntity ?instrument . | ||
| } | ||
| """ | ||
| ] ; | ||
|
|
||
| sh:rule [ | ||
| a sh:TripleRule ; | ||
| sh:subject sh:this ; | ||
| sh:predicate rdf:type ; | ||
| sh:object ro-crate:WorkflowRunAction ; | ||
| ] . | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,7 +22,7 @@ | |||||||||||||
| @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| five-safes-crate:RootDataEntityMentionsCreateAction | ||||||||||||||
| five-safes-crate:RootDataEntityMentionsWorkflowRunAction | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this test ( Can you check, and see if they are the same test, and if so then decide if we should keep the MUST or the SHOULD version?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the excel file we have
@elichad, do you still hold the same opinion about the second rule in the table above? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, just double checked this, the second rule is redundant. The MUST version in this file is the one we should keep.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The redundant rule of phase 11 (Workflow Execution Phase) has been removed. |
||||||||||||||
| a sh:NodeShape ; | ||||||||||||||
| sh:name "RootDataEntity" ; | ||||||||||||||
| sh:targetClass ro-crate:RootDataEntity ; | ||||||||||||||
|
|
@@ -33,42 +33,43 @@ five-safes-crate:RootDataEntityMentionsCreateAction | |||||||||||||
| sh:name "mentions" ; | ||||||||||||||
| sh:path schema:mentions; | ||||||||||||||
| sh:qualifiedValueShape [ | ||||||||||||||
| sh:class schema:CreateAction ; | ||||||||||||||
| sh:class ro-crate:WorkflowRunAction ; | ||||||||||||||
| ] ; | ||||||||||||||
| sh:qualifiedMinCount 1 ; | ||||||||||||||
| sh:severity sh:Violation ; | ||||||||||||||
| sh:message "`RootDataEntity` MUST reference at least one `CreateAction` through `mentions`" ; | ||||||||||||||
| sh:message "`RootDataEntity` MUST reference at least one `CreateAction` (corresponding to the workflow run) through `mentions`" ; | ||||||||||||||
| ] . | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| five-safes-crate:CreateActionInstrumentAndStatus | ||||||||||||||
| five-safes-crate:WorkflowRunActionExistence | ||||||||||||||
| a sh:NodeShape ; | ||||||||||||||
| sh:name "CreateAction" ; | ||||||||||||||
| sh:targetClass schema:CreateAction ; | ||||||||||||||
| sh:description "" ; | ||||||||||||||
| sh:severity sh:Violation ; # Apply to all property shapes / constraints below | ||||||||||||||
| sh:name "RootDataEntity" ; | ||||||||||||||
| sh:targetClass ro-crate:RootDataEntity ; | ||||||||||||||
| sh:description "" ; | ||||||||||||||
|
|
||||||||||||||
| sh:property [ | ||||||||||||||
| a sh:PropertyShape ; | ||||||||||||||
| sh:name "instrument" ; | ||||||||||||||
| sh:path schema:instrument; | ||||||||||||||
| sh:minCount 1 ; | ||||||||||||||
| sh:message "`CreateAction` MUST have the `instrument` property" ; | ||||||||||||||
| ] ; | ||||||||||||||
| sh:sparql [ | ||||||||||||||
| a sh:SPARQLConstraint ; | ||||||||||||||
| sh:name "instrument" ; | ||||||||||||||
| sh:name "WorkflowRunAction" ; | ||||||||||||||
| sh:prefixes ro-crate:sparqlPrefixes ; | ||||||||||||||
| sh:select """ | ||||||||||||||
| SELECT $this ?main ?instrument | ||||||||||||||
| WHERE { | ||||||||||||||
| ?root schema:mainEntity ?main . | ||||||||||||||
| $this schema:instrument ?instrument . | ||||||||||||||
| FILTER (?instrument != ?main) | ||||||||||||||
| } | ||||||||||||||
| SELECT $this | ||||||||||||||
| WHERE { | ||||||||||||||
| FILTER NOT EXISTS { | ||||||||||||||
| ?workflowRunAction a ro-crate:WorkflowRunAction . | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| """ ; | ||||||||||||||
| sh:message "`CreateAction` --> `instrument` MUST reference the same entity as `Root Data Entity` --> `mainEntity`" ; | ||||||||||||||
| ] ; | ||||||||||||||
| sh:message "The CreateAction entity corresponding to the workflow MUST reference, as an instrument, the entity that is referenced as mainEntity by the RO-Crate" ; | ||||||||||||||
| ] . | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| five-safes-crate:WorkflowRunObject | ||||||||||||||
| a sh:NodeShape ; | ||||||||||||||
| sh:name "WorkflowRunAction" ; | ||||||||||||||
| sh:targetClass ro-crate:WorkflowRunAction ; | ||||||||||||||
| sh:description "" ; | ||||||||||||||
| sh:severity sh:Violation ; # Apply to all property shapes / constraints below | ||||||||||||||
|
|
||||||||||||||
| sh:sparql [ | ||||||||||||||
| a sh:SPARQLConstraint ; | ||||||||||||||
| sh:prefixes ro-crate:sparqlPrefixes ; | ||||||||||||||
|
|
@@ -80,5 +81,5 @@ five-safes-crate:CreateActionInstrumentAndStatus | |||||||||||||
| FILTER NOT EXISTS { ?object a ?type . } | ||||||||||||||
| } | ||||||||||||||
| """ ; | ||||||||||||||
| sh:message "Each `object` in `CreateAction` MUST reference an existing entity." ; | ||||||||||||||
| ] . | ||||||||||||||
| sh:message "In the `CreateAction` entity corresponding to the workflow run, each `object` MUST reference an existing entity." ; | ||||||||||||||
| ] . | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Copyright (c) 2024-2026 CRS4 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| @prefix ro: <./> . | ||
| @prefix owl: <http://www.w3.org/2002/07/owl#> . | ||
| @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
| @prefix xml: <http://www.w3.org/XML/1998/namespace#> . | ||
| @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
| @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
| @prefix schema: <http://schema.org/> . | ||
| @prefix rocrate: <https://w3id.org/ro/crate/1.1/> . | ||
| @prefix bioschemas: <https://bioschemas.org/> . | ||
| @prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> . | ||
| @prefix isa-ro-crate: <https://github.com/crs4/rocrate-validator/profiles/isa-ro-crate/> . | ||
|
|
||
| <urn:absolute:.> rdf:type owl:Ontology ; | ||
| owl:versionIRI <urn:absolute:1.0> . | ||
|
|
||
| # # ################################################################# | ||
| # # # Classes | ||
| # # ################################################################# | ||
|
|
||
| # Declare a WorkflowRunAction class | ||
| ro-crate:WorkflowRunAction rdf:type owl:Class ; | ||
| rdfs:subClassOf schema:CreateAction ; | ||
| rdfs:label "WorkflowRunAction"@en . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did some digging into
sh:order. As I noted previously (#104 (comment)), the SHACL docs imply that these lines should not do anything ("sh:orderis not used for validation purposes") However, if I remove them, some tests do fail, so it clearly does do something for us here.I just discovered why it does work - pySHACL uses
sh:orderto apply rules iteratively. See RDFLib/pySHACL#77.This is a bit of a surprise behaviour so I suggest we add comments to these lines explaining why they work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, it's actually part of the SHACL Advanced Features too. https://www.w3.org/TR/shacl-af/#rules-order