-
Notifications
You must be signed in to change notification settings - Fork 0
Infer WorkflowRun from CreateAction in five-safes SHACL profiles #104
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
b7df62f
a15258e
2bd4354
8f19274
5b948c1
08dd31e
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:WorkflowRun ; | ||
| ] . | ||
| 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:RootDataEntityMentionsWorkflowRun | ||||||
| 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:WorkflowRun ; | ||||||
| ] ; | ||||||
| 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:WorkflowRunExistence | ||||||
| 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 "WorkflowRun" ; | ||||||
| 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 { | ||||||
| ?workflowRun a ro-crate:WorkflowRun . | ||||||
| } | ||||||
| } | ||||||
| """ ; | ||||||
| sh:message "`CreateAction` --> `instrument` MUST reference the same entity as `Root Data Entity` --> `mainEntity`" ; | ||||||
| ] ; | ||||||
| sh:message "The crate MUST contain at least one `CreateAction` (corresponding to the workflow run)" ; | ||||||
|
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. This message could be clearer about how the user can resolve the issue - combine the new message with the old message? |
||||||
| ] . | ||||||
|
|
||||||
|
|
||||||
| five-safes-crate:WorkflowRunObject | ||||||
| a sh:NodeShape ; | ||||||
| sh:name "WorkflowRun" ; | ||||||
| sh:targetClass ro-crate:WorkflowRun ; | ||||||
| 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 "Each `object` in the `CreateAction` entity corresponding to the workflow run MUST reference an existing entity." ; | ||||||
|
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.
Suggested change
|
||||||
| ] . | ||||||
| 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 WorkflowRun class | ||
| ro-crate:WorkflowRun rdf:type owl:Class ; | ||
|
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. might be too late for this, but I think a slightly preferable name for this class would be |
||
| rdfs:subClassOf schema:CreateAction ; | ||
| rdfs:label "WorkflowRun"@en . | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,47 +23,46 @@ | |||||
| @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
| five-safes-crate:RootDataEntityShouldMentionWorkflow | ||||||
| a sh:NodeShape ; | ||||||
| sh:name "RootDataEntity" ; | ||||||
| sh:description "RootDataEntity SHOULD mention workflow execution object (typed CreateAction)." ; | ||||||
| sh:description "RootDataEntity SHOULD mention a workflow run object (typed CreateAction)." ; | ||||||
| sh:targetClass ro-crate:RootDataEntity ; | ||||||
| sh:sparql [ | ||||||
| a sh:SPARQLConstraint ; | ||||||
| sh:name "mentions" ; | ||||||
| sh:select """ | ||||||
| PREFIX schema: <http://schema.org/> | ||||||
| PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | ||||||
| PREFIX rocrate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> | ||||||
| SELECT $this | ||||||
| WHERE { | ||||||
|
|
||||||
| FILTER NOT EXISTS { | ||||||
| $this schema:mentions ?workflowExecution . | ||||||
| ?workflowExecution rdf:type schema:CreateAction . | ||||||
| ?workflowExecution a rocrate:WorkflowRun . | ||||||
| } | ||||||
| } | ||||||
| """ ; | ||||||
| sh:severity sh:Warning ; | ||||||
| sh:message "RootDataEntity SHOULD mention workflow execution object (typed CreateAction)." ; | ||||||
| sh:message "RootDataEntity SHOULD mention a workflow run object (typed CreateAction)." ; | ||||||
|
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.
Suggested change
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. after making this comment I just noticed there's a very similar message in some of our tests - https://github.com/eScienceLab/rocrate-validator/pull/104/changes#diff-ddb895f3dbdf2ce99bcefe65919fb782c019baca128c2410f57823c73c8f84a9R88 - do we have two tests doing the same thing? |
||||||
| ] . | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
| five-safes-crate:WorkflowexecutionObjectHasEndTimeIfEnded | ||||||
| a sh:NodeShape ; | ||||||
| sh:name "WorkflowExecution" ; | ||||||
| sh:description "The workflow execution object SHOULD have an endTime property if it has ended." ; | ||||||
| sh:description "The workflow run object SHOULD have an endTime property if it has ended." ; | ||||||
|
|
||||||
| sh:target [ | ||||||
| a sh:SPARQLTarget ; | ||||||
| sh:select """ | ||||||
| PREFIX schema: <http://schema.org/> | ||||||
| PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | ||||||
| PREFIX rocrate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> | ||||||
|
|
||||||
| SELECT ?this | ||||||
| WHERE { | ||||||
| ?this rdf:type schema:CreateAction ; | ||||||
| ?this a rocrate:WorkflowRun ; | ||||||
| schema:actionStatus ?status . | ||||||
| FILTER(?status IN ( | ||||||
| "http://schema.org/CompletedActionStatus", | ||||||
|
|
@@ -82,4 +81,4 @@ five-safes-crate:WorkflowexecutionObjectHasEndTimeIfEnded | |||||
| sh:severity sh:Warning ; | ||||||
| sh:description "The workflow execution object SHOULD have an endTime property if it has ended." ; | ||||||
| sh:message "The workflow execution object SHOULD have an endTime property if it has ended." ; | ||||||
| ] . | ||||||
| ] . | ||||||
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.
Same comment about
sh:orderhere