Comments (4)
@fils
I couldn't wait until after 1.0. 😛 I spent some time today and I've implemented basic owl:imports
support.
I tested your example and it seems to work now, with the new version v0.9.10
.
Some caveats (as much for me to document it somewhere, as it is potentially informational for you):
- It only works 3 levels deep (plus the base level), for example, if a.ttl imports b.ttl, and b.ttl imports c.ttl, and c.ttl imports d.ttl, that is the max it can go, anything that d.ttl imports will be ignored.
- It only works on the SHACL Shapes graph file, and the extra ontology graph file. You cannot use
owl:imports
in the Data graph (well you can, but it doesn't do anything). - It only works if the
owl:imports
statement is assigned on the base uri of the file.
#baseURI: http://example.com/myontology
@prefix owl: <http://www.w3.org/2002/07/owl#> .
<http://example.com/myontology> owl:imports <http://example.com/nextfile> .
- OR on the URI you have defined as a blank prefix:
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix : <http://example.com/myontology#> .
: owl:imports <http://example.com/nextfile> .
- OR if you have explicitly assigned the subject as an
owl:Ontology
:
@prefix owl: <http://www.w3.org/2002/07/owl#> .
<http://example.com/myontology> rdf:type owl:Ontology ;
owl:imports <http://example.com/nextfile> .
from pyshacl.
@ashleysommer Oh sweet! I'm in transit today but I'll try this at the hotel. I'm actually heading to a semantics conf in Durham, so I'm hoping to get some time to chat SHACL with people..
thanks!
from pyshacl.
@fils
Thanks for using pyShacl!
Firstly, there is nothing technically wrong with what you are doing. The owl:imports
axiom allows you to declare that the base graph should be expanded with the contents of an external graph. And using a GitHub raw file URL is a valid location to point it at.
However there a couple of reasons it isn't working for you in this case.
owl:imports
is a statement from OWL2 ontology and is an OWL construct. This means it doesn't do anything on its own by simply existing in your Shapes File. PyShacl uses RDFlib
under the hood for loading and parsing RDF files to graphs. RDFlib doesn't do anything special when it sees an owl:imports, it doesn't follow it and doesn't download or include anything else. If you were to run this graph through an OWL2-compliant graph-expander then it may download and include the target file into the graph, or not, depending on the graph-expander's import policy.
PyShacl has an optional argument that instructs the validator to run an OWL2 reasoning/inferencing graph-expander on the Data-Graph prior to validating, but that doesn't apply to the Shapes Graph. And even if it did, the OWL2 library we use (OWL-RL) has a no-imports policy so it wouldn't work anyway.
So why do they use owl:imports
in the examples in that book?
I'm guessing other SHACL implementations have a special-case rule that looks for owl:imports
in a loaded Shapes File graph, and downloads and includes them. Or that feature is present in the backing RDF loading/parsing library they are based on.
We have certainly discussed the pros and cons of including such a feature in pyShacl. And your creation of this issue will reignite that conversation. There is a chance it will be added in the future, but it will be post-1.0.
from pyshacl.
Thanks for taking the time for that very detailed and very helpful post! Much appreciated!
I'll keep watching to see any further development and for now will just return to the concept of keeping my shape graphs as self contained files. Or I can just break them up and do run multiple runs of pyshacl for the various sets of shapes to test, like required, recommended, etc. etc.
To give you some context to all this. Several of us are working on schema.org based metadata for various data facilities and some government agencies. One issue though is that some of the tooling is a bit lacking. (I'm looking at you, Google Structured Data Testing Tool) So a thought has been to define the shapes we are after and essentially do a sort of "test driven development" pattern from software land. This also lets us ensure that extensions to schema.org, which we need, can be checked since SDTT just throughs them as errors.
Thanks!
I'm curious to give this a try and this is the start of all that.
from pyshacl.
Related Issues (20)
- [Discussion] Pinned vs loose requirements, application vs library use cases HOT 5
- SPARQL ASK rule incorrectly passing HOT 7
- Can the prettytable dependency be upgraded to major version 3? HOT 1
- Generating SHACL-SPARQL shapes in RDFLib HOT 2
- Shacl does not seem to work on rdflib.Dataset() HOT 1
- Unable to see the validation result in pyshacl HOT 2
- How to ensure subject is not a sh:BlankNode when validating a owl:Class in an ontology? HOT 4
- owl:imports for data graph is hardcoded to false HOT 2
- pySHACL uses deprecated API `pkg_resources` HOT 4
- Trouble with qualified value shape HOT 6
- Failed to catch violations with properties that are not defined HOT 8
- Is a shape (whether node or property) restricted to one instance of sh:not? HOT 5
- Multiple sh:nots causing strange validation results HOT 2
- Multiple sh:xones on one sh:NodeShape grouping member shapes causing unexpected validation results
- `sh:entailment` and `pyshacl --advanced` HOT 1
- `sh:severity` on shapes linked by `sh:node` HOT 2
- `_evaluation_path` length is not configurable HOT 3
- [Discussion] Higher performance "remote" validation
- Difference between PySHACL and TopBraid SHACL API HOT 1
- Message: Node ex:**** does not contain a value in the set: ['Literal("true" = True, datatype=xsd:boolean)'] HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyshacl.