Skip to content

Commit b7df62f

Browse files
committed
Infer WorkflowRun from CreateAction in five-safes SHACL profiles
1 parent 6a6f98d commit b7df62f

18 files changed

+463
-167
lines changed

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

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

2424

25+
ro-crate:FindWorkflowRunAction a sh:NodeShape, validator:HiddenShape;
26+
sh:name "Identify the CreateAction Entity that corresponds to the Workflow run" ;
27+
sh:description """The Workflow Run is the CreateAction entity that refers to Workflow run.
28+
This is identified by checking that the CreateAction entity has an `instrument` property
29+
that references the same entity as the `mainEntity` property of the Root Data Entity.""" ;
30+
sh:target [
31+
a sh:SPARQLTarget ;
32+
sh:prefixes ro-crate:sparqlPrefixes ;
33+
sh:select """
34+
SELECT ?this
35+
WHERE {
36+
?this a schema:CreateAction ;
37+
schema:instrument ?instrument .
38+
?root schema:mainEntity ?instrument ;
39+
a schema:Dataset .
40+
?metadatafile schema:about ?root .
41+
FILTER(contains(str(?metadatafile), "ro-crate-metadata.json"))
42+
}
43+
"""
44+
] ;
45+
46+
sh:rule [
47+
a sh:TripleRule ;
48+
sh:subject sh:this ;
49+
sh:predicate rdf:type ;
50+
sh:object ro-crate:WorkflowRun ;
51+
] .
52+
53+
2554
five-safes-crate:WorkflowexecutionObjectHasStartTimeIfBegun
2655
a sh:NodeShape ;
2756
sh:name "WorkflowExecution" ;
@@ -34,11 +63,11 @@ five-safes-crate:WorkflowexecutionObjectHasStartTimeIfBegun
3463
a sh:SPARQLTarget ;
3564
sh:select """
3665
PREFIX schema: <http://schema.org/>
37-
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
66+
PREFIX rocrate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/>
3867
3968
SELECT ?this
4069
WHERE {
41-
?this rdf:type schema:CreateAction ;
70+
?this a rocrate:WorkflowRun ;
4271
schema:actionStatus ?status .
4372
FILTER(?status IN (
4473
"http://schema.org/CompletedActionStatus",

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

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

2424

25+
ro-crate:FindWorkflowRunAction a sh:NodeShape, validator:HiddenShape;
26+
sh:name "Identify the CreateAction Entity that corresponds to the Workflow run" ;
27+
sh:description """The Workflow Run is the CreateAction entity that refers to Workflow run.
28+
This is identified by checking that the CreateAction entity has an `instrument` property
29+
that references the same entity as the `mainEntity` property of the Root Data Entity.""" ;
30+
sh:target [
31+
a sh:SPARQLTarget ;
32+
sh:prefixes ro-crate:sparqlPrefixes ;
33+
sh:select """
34+
SELECT ?this
35+
WHERE {
36+
?this a schema:CreateAction ;
37+
schema:instrument ?instrument .
38+
?root schema:mainEntity ?instrument ;
39+
a schema:Dataset .
40+
?metadatafile schema:about ?root .
41+
FILTER(contains(str(?metadatafile), "ro-crate-metadata.json"))
42+
}
43+
"""
44+
] ;
45+
46+
sh:rule [
47+
a sh:TripleRule ;
48+
sh:subject sh:this ;
49+
sh:predicate rdf:type ;
50+
sh:object ro-crate:WorkflowRun ;
51+
] .
52+
53+
2554
five-safes-crate:ResponsibleProject
2655
a sh:NodeShape ;
2756
sh:name "Responsible Project" ;
@@ -30,7 +59,7 @@ five-safes-crate:ResponsibleProject
3059
sh:prefixes ro-crate:sparqlPrefixes ;
3160
sh:select """
3261
SELECT DISTINCT ?this WHERE {
33-
?action a schema:CreateAction ;
62+
?action a ro-crate:WorkflowRun ;
3463
schema:agent ?agent .
3564
?agent schema:memberOf ?this .
3665
}
@@ -53,4 +82,4 @@ five-safes-crate:ResponsibleProject
5382
sh:minCount 1 ;
5483
sh:severity sh:Info ;
5584
sh:message """The Responsible Project does not have the property `member`.""" ;
56-
] .
85+
] .

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

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,62 @@
2323
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
2424

2525

26+
ro-crate:FindWorkflowRunAction a sh:NodeShape, validator:HiddenShape;
27+
sh:name "Identify the CreateAction Entity that corresponds to the Workflow run" ;
28+
sh:description """The Workflow Run is the CreateAction entity that refers to Workflow run.
29+
This is identified by checking that the CreateAction entity has an `instrument` property
30+
that references the same entity as the `mainEntity` property of the Root Data Entity.""" ;
31+
sh:target [
32+
a sh:SPARQLTarget ;
33+
sh:prefixes ro-crate:sparqlPrefixes ;
34+
sh:select """
35+
SELECT ?this
36+
WHERE {
37+
?this a schema:CreateAction ;
38+
schema:instrument ?instrument .
39+
?root schema:mainEntity ?instrument ;
40+
a schema:Dataset .
41+
?metadatafile schema:about ?root .
42+
FILTER(contains(str(?metadatafile), "ro-crate-metadata.json"))
43+
}
44+
"""
45+
] ;
46+
47+
sh:rule [
48+
a sh:TripleRule ;
49+
sh:subject sh:this ;
50+
sh:predicate rdf:type ;
51+
sh:object ro-crate:WorkflowRun ;
52+
] .
53+
54+
2655
five-safes-crate:WorkflowMustHaveDescriptiveName
2756
a sh:NodeShape ;
2857
sh:name "WorkflowExecution" ;
29-
sh:targetClass schema:CreateAction ;
58+
sh:targetClass ro-crate:WorkflowRun ;
3059

3160
sh:property [
3261
a sh:PropertyShape ;
3362
sh:name "name" ;
3463
sh:minCount 1 ;
35-
sh:description "Workflow (CreateAction) MUST have a name string of at least 10 characters." ;
64+
sh:description "WorkflowRun MUST have a name string of at least 10 characters." ;
3665
sh:path schema:name ;
3766
sh:datatype xsd:string ;
3867
sh:minLength 10 ;
3968
sh:severity sh:Violation ;
40-
sh:message "Workflow (CreateAction) MUST have a name string of at least 10 characters." ;
69+
sh:message "WorkflowRun MUST have a name string of at least 10 characters." ;
4170
] .
4271

4372

4473
five-safes-crate:WorkflowMustHaveActionStatusWithAllowedValues
4574
a sh:NodeShape ;
4675
sh:name "WorkflowExecution" ;
47-
sh:targetClass schema:CreateAction ;
76+
sh:targetClass ro-crate:WorkflowRun ;
4877
sh:property [
4978
a sh:PropertyShape ;
5079
sh:minCount 1 ;
5180
sh:name "actionStatus" ;
52-
sh:description "WorkflowExecution MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
81+
sh:description "WorkflowRun MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
5382
sh:path schema:actionStatus ;
5483
sh:in (
5584
"http://schema.org/PotentialActionStatus"
@@ -58,5 +87,5 @@ five-safes-crate:WorkflowMustHaveActionStatusWithAllowedValues
5887
"http://schema.org/FailedActionStatus"
5988
) ;
6089
sh:severity sh:Violation ;
61-
sh:message "WorkflowExecution MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
90+
sh:message "WorkflowRun MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
6291
] .

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

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

2424

25-
five-safes-crate:RootDataEntityMentionsCreateAction
25+
ro-crate:FindWorkflowRunAction a sh:NodeShape, validator:HiddenShape;
26+
sh:name "Identify the CreateAction Entity that corresponds to the Workflow run" ;
27+
sh:description """The Workflow Run is the CreateAction entity that refers to Workflow run.
28+
This is identified by checking that the CreateAction entity has an `instrument` property
29+
that references the same entity as the `mainEntity` property of the Root Data Entity.""" ;
30+
sh:target [
31+
a sh:SPARQLTarget ;
32+
sh:prefixes ro-crate:sparqlPrefixes ;
33+
sh:select """
34+
SELECT ?this
35+
WHERE {
36+
?this a schema:CreateAction ;
37+
schema:instrument ?instrument .
38+
?root schema:mainEntity ?instrument ;
39+
a schema:Dataset .
40+
?metadatafile schema:about ?root .
41+
FILTER(contains(str(?metadatafile), "ro-crate-metadata.json"))
42+
}
43+
"""
44+
] ;
45+
46+
# Expand data graph with triples from the file data entity
47+
sh:rule [
48+
a sh:TripleRule ;
49+
sh:subject sh:this ;
50+
sh:predicate rdf:type ;
51+
sh:object ro-crate:WorkflowRun ;
52+
] .
53+
54+
55+
five-safes-crate:RootDataEntityMentionsWorkflowRun
2656
a sh:NodeShape ;
2757
sh:name "RootDataEntity" ;
2858
sh:targetClass ro-crate:RootDataEntity ;
@@ -33,42 +63,43 @@ five-safes-crate:RootDataEntityMentionsCreateAction
3363
sh:name "mentions" ;
3464
sh:path schema:mentions;
3565
sh:qualifiedValueShape [
36-
sh:class schema:CreateAction ;
66+
sh:class ro-crate:WorkflowRun ;
3767
] ;
3868
sh:qualifiedMinCount 1 ;
3969
sh:severity sh:Violation ;
40-
sh:message "`RootDataEntity` MUST reference at least one `CreateAction` through `mentions`" ;
70+
sh:message "`RootDataEntity` MUST reference at least one `WorkflowRun` through `mentions`" ;
4171
] .
4272

4373

44-
five-safes-crate:CreateActionInstrumentAndStatus
74+
five-safes-crate:WorkflowRunExistence
4575
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
76+
sh:name "RootDataEntity" ;
77+
sh:targetClass ro-crate:RootDataEntity ;
78+
sh:description "" ;
5079

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-
] ;
5880
sh:sparql [
5981
a sh:SPARQLConstraint ;
60-
sh:name "instrument" ;
82+
sh:name "WorkflowRun" ;
6183
sh:prefixes ro-crate:sparqlPrefixes ;
6284
sh:select """
63-
SELECT $this ?main ?instrument
64-
WHERE {
65-
?root schema:mainEntity ?main .
66-
$this schema:instrument ?instrument .
67-
FILTER (?instrument != ?main)
68-
}
85+
SELECT $this
86+
WHERE {
87+
FILTER NOT EXISTS {
88+
?workflowRun a ro-crate:WorkflowRun .
89+
}
90+
}
6991
""" ;
70-
sh:message "`CreateAction` --> `instrument` MUST reference the same entity as `Root Data Entity` --> `mainEntity`" ;
71-
] ;
92+
sh:message "The crate MUST contain at least one `WorkflowRun` entity" ;
93+
] .
94+
95+
96+
five-safes-crate:WorkflowRunObject
97+
a sh:NodeShape ;
98+
sh:name "WorkflowRun" ;
99+
sh:targetClass ro-crate:WorkflowRun ;
100+
sh:description "" ;
101+
sh:severity sh:Violation ; # Apply to all property shapes / constraints below
102+
72103
sh:sparql [
73104
a sh:SPARQLConstraint ;
74105
sh:prefixes ro-crate:sparqlPrefixes ;
@@ -80,5 +111,5 @@ five-safes-crate:CreateActionInstrumentAndStatus
80111
FILTER NOT EXISTS { ?object a ?type . }
81112
}
82113
""" ;
83-
sh:message "Each `object` in `CreateAction` MUST reference an existing entity." ;
84-
] .
114+
sh:message "Each `object` in `WorkflowRun` MUST reference an existing entity." ;
115+
] .
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 WorkflowRun class
35+
ro-crate:WorkflowRun rdf:type owl:Class ;
36+
rdfs:subClassOf schema:CreateAction ;
37+
rdfs:label "WorkflowRun"@en .

0 commit comments

Comments
 (0)