-
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 1 commit
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 |
|---|---|---|
|
|
@@ -22,6 +22,35 @@ | |
| @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
|
|
||
|
|
||
| ro-crate:FindWorkflowRunAction a sh:NodeShape, validator:HiddenShape; | ||
| 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 schema:mainEntity ?instrument ; | ||
| a schema:Dataset . | ||
| ?metadatafile schema:about ?root . | ||
| FILTER(contains(str(?metadatafile), "ro-crate-metadata.json")) | ||
| } | ||
| """ | ||
|
||
| ] ; | ||
|
|
||
| sh:rule [ | ||
| a sh:TripleRule ; | ||
| sh:subject sh:this ; | ||
| sh:predicate rdf:type ; | ||
| sh:object ro-crate:WorkflowRun ; | ||
| ] . | ||
|
|
||
|
|
||
| five-safes-crate:WorkflowexecutionObjectHasStartTimeIfBegun | ||
| a sh:NodeShape ; | ||
| sh:name "WorkflowExecution" ; | ||
|
|
@@ -34,11 +63,11 @@ five-safes-crate:WorkflowexecutionObjectHasStartTimeIfBegun | |
| 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", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,33 +23,62 @@ | |
| @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
|
|
||
|
|
||
| ro-crate:FindWorkflowRunAction a sh:NodeShape, validator:HiddenShape; | ||
| 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 schema:mainEntity ?instrument ; | ||
| a schema:Dataset . | ||
| ?metadatafile schema:about ?root . | ||
| FILTER(contains(str(?metadatafile), "ro-crate-metadata.json")) | ||
| } | ||
| """ | ||
| ] ; | ||
|
|
||
| sh:rule [ | ||
| a sh:TripleRule ; | ||
| sh:subject sh:this ; | ||
| sh:predicate rdf:type ; | ||
| sh:object ro-crate:WorkflowRun ; | ||
| ] . | ||
|
|
||
|
|
||
| five-safes-crate:WorkflowMustHaveDescriptiveName | ||
| a sh:NodeShape ; | ||
| sh:name "WorkflowExecution" ; | ||
| sh:targetClass schema:CreateAction ; | ||
| sh:targetClass ro-crate:WorkflowRun ; | ||
|
|
||
| sh:property [ | ||
| a sh:PropertyShape ; | ||
| sh:name "name" ; | ||
| sh:minCount 1 ; | ||
| sh:description "Workflow (CreateAction) MUST have a name string of at least 10 characters." ; | ||
| sh:description "WorkflowRun MUST have a name string of at least 10 characters." ; | ||
| sh:path schema:name ; | ||
| sh:datatype xsd:string ; | ||
| sh:minLength 10 ; | ||
| sh:severity sh:Violation ; | ||
| sh:message "Workflow (CreateAction) MUST have a name string of at least 10 characters." ; | ||
| sh:message "WorkflowRun MUST have a name string of at least 10 characters." ; | ||
|
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. I'm just going to comment on this one change - but this applies through the changes we've made. I don't think that we should be mentioning |
||
| ] . | ||
|
|
||
|
|
||
| five-safes-crate:WorkflowMustHaveActionStatusWithAllowedValues | ||
| a sh:NodeShape ; | ||
| sh:name "WorkflowExecution" ; | ||
| sh:targetClass schema:CreateAction ; | ||
| sh:targetClass ro-crate:WorkflowRun ; | ||
| sh:property [ | ||
| a sh:PropertyShape ; | ||
| sh:minCount 1 ; | ||
| sh:name "actionStatus" ; | ||
| sh:description "WorkflowExecution MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ; | ||
| sh:description "WorkflowRun MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ; | ||
| sh:path schema:actionStatus ; | ||
| sh:in ( | ||
| "http://schema.org/PotentialActionStatus" | ||
|
|
@@ -58,5 +87,5 @@ five-safes-crate:WorkflowMustHaveActionStatusWithAllowedValues | |
| "http://schema.org/FailedActionStatus" | ||
| ) ; | ||
| sh:severity sh:Violation ; | ||
| sh:message "WorkflowExecution MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ; | ||
| sh:message "WorkflowRun MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ; | ||
| ] . | ||
| 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 ; | ||
| rdfs:subClassOf schema:CreateAction ; | ||
| rdfs:label "WorkflowRun"@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.
This code block is duplicated across quite a few files. If we have to change anything we'll need to change this across ~10 different files. Can this be centralised?
Uh oh!
There was an error while loading. Please reload this page.
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.
Ideally, but as far as I know there is no import directive for
ttlfiles.I will investigate whether the import is possibly done via code, and, in that case, centralise that code block.
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.
My impression is that all the .ttl files are loaded together and combined after selecting profiles but before the validation is run - this is what allows us to use
ro-crate:RootDataEntityfreely, and it's why this particular line works to disable a check from the base spec:rocrate-validator/rocrate_validator/profiles/five-safes-crate/must/15_metadata_file.ttl
Line 41 in 6a6f98d
So I don't think we need to import another .ttl file in order to reuse this block, we just need to make sure it's in a .ttl file that definitely gets loaded for this profile, which are the ones in the
must/folder (should/andmay/only seem to be loaded if those severities are explicitly selected).I tried removing this block from all files except
must/7_requested_workflow_run.ttland it seems to work. Can you try that on your side @EttoreM ?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.
(also, more for info, there is an import mechanism in SHACL - https://book.validatingrdf.com/bookHtml011.html#sec126 - but I think this won't work in these files as the shapes are not directly resolvable at the URI we use for the profile)
Uh oh!
There was an error while loading. Please reload this page.
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.
Thank you @elichad. My last commit does precisely what you suggests, with the exception that the code-block in question has been put in its own file under the MUST folder. It seems to be as a cleaner solution rather than having it in any of the existing file. In the end, that code-block does not enforce a SHACL rules, so to speak, but rather modify the graph before SHACL validation can be run.
Also I made the dependency of
WorkflowRunonRootDataEntityexplicit. To do this I addedsh:order 0inFindRootDataEntity(2_root_data_entity_metadata.ttl), andsh:order 1inFindWorkflowRunAction. This ensures thatRootDataEntityis inferred first, then theWorkflowRun.