Skip to content

Commit cd58c3c

Browse files
authored
Merge pull request #109 from eScienceLab/107-run-createaction-checks-only-against-the-createactions-that-the-profile-cares-about
Infer WorkflowRun from CreateAction in five-safes SHACL profiles - NEW
2 parents b1e35f5 + 8a42e4f commit cd58c3c

20 files changed

Lines changed: 196 additions & 218 deletions

rocrate_validator/profiles/five-safes-crate/may/11_workflow_execution_phase.ttl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ five-safes-crate:WorkflowexecutionObjectHasStartTimeIfBegun
3434
a sh:SPARQLTarget ;
3535
sh:select """
3636
PREFIX schema: <http://schema.org/>
37-
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
37+
PREFIX rocrate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/>
3838
3939
SELECT ?this
4040
WHERE {
41-
?this rdf:type schema:CreateAction ;
41+
?this a rocrate:WorkflowRunAction ;
4242
schema:actionStatus ?status .
4343
FILTER(?status IN (
4444
"http://schema.org/CompletedActionStatus",

rocrate_validator/profiles/five-safes-crate/may/1_responsible_project.ttl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ five-safes-crate:ResponsibleProject
3030
sh:prefixes ro-crate:sparqlPrefixes ;
3131
sh:select """
3232
SELECT DISTINCT ?this WHERE {
33-
?action a schema:CreateAction ;
33+
?action a ro-crate:WorkflowRunAction ;
3434
schema:agent ?agent .
3535
?agent schema:memberOf ?this .
3636
}
@@ -53,4 +53,4 @@ five-safes-crate:ResponsibleProject
5353
sh:minCount 1 ;
5454
sh:severity sh:Info ;
5555
sh:message """The Responsible Project does not have the property `member`.""" ;
56-
] .
56+
] .
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright (c) 2025 eScience Lab, The University of Manchester
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
16+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
17+
@prefix schema: <http://schema.org/> .
18+
@prefix sh: <http://www.w3.org/ns/shacl#> .
19+
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
20+
21+
22+
ro-crate:FindWorkflowRunAction a sh:NodeShape, validator:HiddenShape;
23+
sh:order 1 ; # load this check after ro-crate:FindRootDataEntity; pySHACL sorts rules by sh:order before execution
24+
sh:name "Identify the CreateAction Entity that corresponds to the Workflow run" ;
25+
sh:description """The Workflow Run is the CreateAction entity that refers to Workflow run.
26+
This is identified by checking that the CreateAction entity has an `instrument` property
27+
that references the same entity as the `mainEntity` property of the Root Data Entity.""" ;
28+
sh:target [
29+
a sh:SPARQLTarget ;
30+
sh:prefixes ro-crate:sparqlPrefixes ;
31+
sh:select """
32+
SELECT ?this
33+
WHERE {
34+
?this a schema:CreateAction ;
35+
schema:instrument ?instrument .
36+
?root a ro-crate:RootDataEntity ;
37+
schema:mainEntity ?instrument .
38+
}
39+
"""
40+
] ;
41+
42+
sh:rule [
43+
a sh:TripleRule ;
44+
sh:subject sh:this ;
45+
sh:predicate rdf:type ;
46+
sh:object ro-crate:WorkflowRunAction ;
47+
] .

rocrate_validator/profiles/five-safes-crate/must/11_workflow_execution_phase.ttl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,30 @@
2626
five-safes-crate:WorkflowMustHaveDescriptiveName
2727
a sh:NodeShape ;
2828
sh:name "WorkflowExecution" ;
29-
sh:targetClass schema:CreateAction ;
29+
sh:targetClass ro-crate:WorkflowRunAction ;
3030

3131
sh:property [
3232
a sh:PropertyShape ;
3333
sh:name "name" ;
3434
sh:minCount 1 ;
35-
sh:description "Workflow (CreateAction) MUST have a name string of at least 10 characters." ;
35+
sh:description "The `CreateAction` corresponding to the workflow run MUST have a name string of at least 10 characters." ;
3636
sh:path schema:name ;
3737
sh:datatype xsd:string ;
3838
sh:minLength 10 ;
3939
sh:severity sh:Violation ;
40-
sh:message "Workflow (CreateAction) MUST have a name string of at least 10 characters." ;
40+
sh:message "The `CreateAction` corresponding to the workflow run MUST have a name string of at least 10 characters." ;
4141
] .
4242

4343

4444
five-safes-crate:WorkflowMustHaveActionStatusWithAllowedValues
4545
a sh:NodeShape ;
4646
sh:name "WorkflowExecution" ;
47-
sh:targetClass schema:CreateAction ;
47+
sh:targetClass ro-crate:WorkflowRunAction ;
4848
sh:property [
4949
a sh:PropertyShape ;
5050
sh:minCount 1 ;
5151
sh:name "actionStatus" ;
52-
sh:description "WorkflowExecution MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
52+
sh:description "`CreateAction` MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
5353
sh:path schema:actionStatus ;
5454
sh:in (
5555
"http://schema.org/PotentialActionStatus"
@@ -58,5 +58,5 @@ five-safes-crate:WorkflowMustHaveActionStatusWithAllowedValues
5858
"http://schema.org/FailedActionStatus"
5959
) ;
6060
sh:severity sh:Violation ;
61-
sh:message "WorkflowExecution MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
61+
sh:message "`CreateAction` MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
6262
] .

rocrate_validator/profiles/five-safes-crate/must/7_requested_workflow_run.ttl

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
2323

2424

25-
five-safes-crate:RootDataEntityMentionsCreateAction
25+
five-safes-crate:RootDataEntityMentionsWorkflowRunAction
2626
a sh:NodeShape ;
2727
sh:name "RootDataEntity" ;
2828
sh:targetClass ro-crate:RootDataEntity ;
@@ -33,42 +33,43 @@ five-safes-crate:RootDataEntityMentionsCreateAction
3333
sh:name "mentions" ;
3434
sh:path schema:mentions;
3535
sh:qualifiedValueShape [
36-
sh:class schema:CreateAction ;
36+
sh:class ro-crate:WorkflowRunAction ;
3737
] ;
3838
sh:qualifiedMinCount 1 ;
3939
sh:severity sh:Violation ;
40-
sh:message "`RootDataEntity` MUST reference at least one `CreateAction` through `mentions`" ;
40+
sh:message "`RootDataEntity` MUST reference at least one `CreateAction` (corresponding to the workflow run) through `mentions`" ;
4141
] .
4242

4343

44-
five-safes-crate:CreateActionInstrumentAndStatus
44+
five-safes-crate:WorkflowRunActionExistence
4545
a sh:NodeShape ;
46-
sh:name "CreateAction" ;
47-
sh:targetClass schema:CreateAction ;
48-
sh:description "" ;
49-
sh:severity sh:Violation ; # Apply to all property shapes / constraints below
46+
sh:name "RootDataEntity" ;
47+
sh:targetClass ro-crate:RootDataEntity ;
48+
sh:description "" ;
5049

51-
sh:property [
52-
a sh:PropertyShape ;
53-
sh:name "instrument" ;
54-
sh:path schema:instrument;
55-
sh:minCount 1 ;
56-
sh:message "`CreateAction` MUST have the `instrument` property" ;
57-
] ;
5850
sh:sparql [
5951
a sh:SPARQLConstraint ;
60-
sh:name "instrument" ;
52+
sh:name "WorkflowRunAction" ;
6153
sh:prefixes ro-crate:sparqlPrefixes ;
6254
sh:select """
63-
SELECT $this ?main ?instrument
64-
WHERE {
65-
?root schema:mainEntity ?main .
66-
$this schema:instrument ?instrument .
67-
FILTER (?instrument != ?main)
68-
}
55+
SELECT $this
56+
WHERE {
57+
FILTER NOT EXISTS {
58+
?workflowRunAction a ro-crate:WorkflowRunAction .
59+
}
60+
}
6961
""" ;
70-
sh:message "`CreateAction` --> `instrument` MUST reference the same entity as `Root Data Entity` --> `mainEntity`" ;
71-
] ;
62+
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" ;
63+
] .
64+
65+
66+
five-safes-crate:WorkflowRunObject
67+
a sh:NodeShape ;
68+
sh:name "WorkflowRunAction" ;
69+
sh:targetClass ro-crate:WorkflowRunAction ;
70+
sh:description "" ;
71+
sh:severity sh:Violation ; # Apply to all property shapes / constraints below
72+
7273
sh:sparql [
7374
a sh:SPARQLConstraint ;
7475
sh:prefixes ro-crate:sparqlPrefixes ;
@@ -80,5 +81,5 @@ five-safes-crate:CreateActionInstrumentAndStatus
8081
FILTER NOT EXISTS { ?object a ?type . }
8182
}
8283
""" ;
83-
sh:message "Each `object` in `CreateAction` MUST reference an existing entity." ;
84-
] .
84+
sh:message "In the `CreateAction` entity corresponding to the workflow run, each `object` MUST reference an existing entity." ;
85+
] .
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (c) 2024-2026 CRS4
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
@prefix ro: <./> .
16+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
17+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
18+
@prefix xml: <http://www.w3.org/XML/1998/namespace#> .
19+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
20+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
21+
@prefix schema: <http://schema.org/> .
22+
@prefix rocrate: <https://w3id.org/ro/crate/1.1/> .
23+
@prefix bioschemas: <https://bioschemas.org/> .
24+
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
25+
@prefix isa-ro-crate: <https://github.com/crs4/rocrate-validator/profiles/isa-ro-crate/> .
26+
27+
<urn:absolute:.> rdf:type owl:Ontology ;
28+
owl:versionIRI <urn:absolute:1.0> .
29+
30+
# # #################################################################
31+
# # # Classes
32+
# # #################################################################
33+
34+
# Declare a WorkflowRunAction class
35+
ro-crate:WorkflowRunAction rdf:type owl:Class ;
36+
rdfs:subClassOf schema:CreateAction ;
37+
rdfs:label "WorkflowRunAction"@en .

rocrate_validator/profiles/five-safes-crate/should/10_outputs.ttl

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,19 @@
2222
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
2323

2424

25-
26-
five-safes-crate:CreateActionHasResultIfActionCompleted
25+
five-safes-crate:WorkflowRunActionHasResultIfActionCompleted
2726
a sh:NodeShape ;
28-
sh:name "CreateAction" ;
29-
sh:description "`CreateAction` with CompletedActionStatus SHOULD have the `schema:result` property." ;
27+
sh:name "WorkflowRunAction" ;
28+
sh:description "The `CreateAction` corresponding to the workflow run, with CompletedActionStatus, SHOULD have the `schema:result` property." ;
3029

3130
sh:target [
3231
a sh:SPARQLTarget ;
33-
sh:name "Result" ;
34-
sh:description "`CreateAction` with CompletedActionStatus SHOULD have the `schema:result` property." ;
32+
sh:name "WorkflowRunAction" ;
33+
sh:description "The `CreateAction` corresponding to the workflow run, with CompletedActionStatus, SHOULD have the `result` property." ;
3534
sh:prefixes ro-crate:sparqlPrefixes ;
3635
sh:select """
3736
SELECT ?this WHERE {
38-
?this a schema:CreateAction ;
37+
?this a ro-crate:WorkflowRunAction ;
3938
schema:actionStatus "http://schema.org/CompletedActionStatus" .
4039
}
4140
"""
@@ -48,22 +47,22 @@ five-safes-crate:CreateActionHasResultIfActionCompleted
4847
sh:path schema:result ;
4948
sh:minCount 1 ;
5049
sh:severity sh:Warning ;
51-
sh:message "`CreateAction` with CompletedActionStatus SHOULD have the `result` property." ;
50+
sh:message "The `CreateAction` corresponding to the workflow run, with CompletedActionStatus, SHOULD have the `result` property." ;
5251
] .
5352

5453

55-
five-safes-crate:CreateActionResultOutputsHaveAllowedTypes
54+
five-safes-crate:WorkflowRunActionResultOutputsHaveAllowedTypes
5655
a sh:NodeShape ;
5756
sh:name "Output" ;
5857
sh:description "Result SHOULD have a `@type` among an allowed set of values." ;
5958
sh:target [
6059
a sh:SPARQLTarget ;
60+
sh:prefixes ro-crate:sparqlPrefixes ;
6161
sh:select """
62-
PREFIX schema: <http://schema.org/>
6362
SELECT ?this
6463
WHERE {
65-
?createAction a schema:CreateAction .
66-
?createAction schema:result ?this .
64+
?workflowRunAction a ro-crate:WorkflowRunAction .
65+
?workflowRunAction schema:result ?this .
6766
}
6867
""" ;
6968
] ;
@@ -86,4 +85,3 @@ five-safes-crate:CreateActionResultOutputsHaveAllowedTypes
8685
sh:class schema:PropertyValue;
8786
]
8887
) .
89-

rocrate_validator/profiles/five-safes-crate/should/11_workflow_execution_phase.ttl

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,20 @@
2323
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
2424

2525

26-
27-
five-safes-crate:RootDataEntityShouldMentionWorkflow
28-
a sh:NodeShape ;
29-
sh:name "RootDataEntity" ;
30-
sh:description "RootDataEntity SHOULD mention workflow execution object (typed CreateAction)." ;
31-
sh:targetClass ro-crate:RootDataEntity ;
32-
sh:sparql [
33-
a sh:SPARQLConstraint ;
34-
sh:name "mentions" ;
35-
sh:select """
36-
PREFIX schema: <http://schema.org/>
37-
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
38-
SELECT $this
39-
WHERE {
40-
41-
FILTER NOT EXISTS {
42-
$this schema:mentions ?workflowExecution .
43-
?workflowExecution rdf:type schema:CreateAction .
44-
}
45-
}
46-
""" ;
47-
sh:severity sh:Warning ;
48-
sh:message "RootDataEntity SHOULD mention workflow execution object (typed CreateAction)." ;
49-
] .
50-
51-
52-
5326
five-safes-crate:WorkflowexecutionObjectHasEndTimeIfEnded
5427
a sh:NodeShape ;
5528
sh:name "WorkflowExecution" ;
56-
sh:description "The workflow execution object SHOULD have an endTime property if it has ended." ;
29+
sh:description "The workflow run object SHOULD have an endTime property if it has ended." ;
5730

5831
sh:target [
5932
a sh:SPARQLTarget ;
6033
sh:select """
6134
PREFIX schema: <http://schema.org/>
62-
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
35+
PREFIX rocrate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/>
6336
6437
SELECT ?this
6538
WHERE {
66-
?this rdf:type schema:CreateAction ;
39+
?this a rocrate:WorkflowRunAction ;
6740
schema:actionStatus ?status .
6841
FILTER(?status IN (
6942
"http://schema.org/CompletedActionStatus",
@@ -82,4 +55,4 @@ five-safes-crate:WorkflowexecutionObjectHasEndTimeIfEnded
8255
sh:severity sh:Warning ;
8356
sh:description "The workflow execution object SHOULD have an endTime property if it has ended." ;
8457
sh:message "The workflow execution object SHOULD have an endTime property if it has ended." ;
85-
] .
58+
] .

rocrate_validator/profiles/five-safes-crate/should/1_requesting_agent.ttl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ five-safes-crate:AgentIsMemberOf
3030
sh:prefixes ro-crate:sparqlPrefixes ;
3131
sh:select """
3232
SELECT DISTINCT ?this WHERE {
33-
?action a schema:CreateAction ;
33+
?action a rocrate:WorkflowRunAction ;
3434
schema:agent ?this .
3535
}
3636
"""
@@ -43,4 +43,4 @@ five-safes-crate:AgentIsMemberOf
4343
sh:minCount 1 ;
4444
sh:severity sh:Warning ;
4545
sh:message """The Requesting Agent SHOULD have a `memberOf` property.""" ;
46-
] .
46+
] .

rocrate_validator/profiles/five-safes-crate/should/1_responsible_project.ttl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ five-safes-crate:ResponsibleProjectMemberAndSourceOrganizationIntersection
3333
sh:prefixes ro-crate:sparqlPrefixes ;
3434
sh:select """
3535
SELECT DISTINCT ?this WHERE {
36-
?action a schema:CreateAction ;
36+
?action a ro-crate:WorkflowRunAction ;
3737
schema:agent ?this .
3838
?this a schema:Person ;
3939
schema:memberOf ?project ;
@@ -59,4 +59,4 @@ five-safes-crate:ResponsibleProjectMemberAndSourceOrganizationIntersection
5959
}
6060
""" ;
6161
sh:message """At least one of the organisations that are members of the responsible project SHOULD be included in the Requesting Agent's affiliations, if such properties exist.""" ;
62-
] .
62+
] .

0 commit comments

Comments
 (0)