Skip to content
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

owl imports of other shape graphs #18

Closed
fils opened this issue Mar 4, 2019 · 4 comments
Closed

owl imports of other shape graphs #18

fils opened this issue Mar 4, 2019 · 4 comments

Comments

@fils
Copy link

@fils fils commented Mar 4, 2019

So, very new to all this... but have a question.

Is it possible to define an owl:imports in a shape file to pull in previously defined shapes from another file? Ref https://github.com/ESIPFed/science-on-schema.org/blob/master/tools/sospy/shapegraphs/reqrec.ttl

I'm looking at https://book.validatingrdf.com/bookHtml011.html section 5.4 for inspiration.

Note: Maybe I'm being too cute trying to import from a github raw URL?

I get a proper violation from the recomended.ttl file, but I can not import it and use it. I don't know if this is not possible or (more likely) I'm doing it wrong.

Thanks

pyshacl -s ./shapegraphs/recomendShape.ttl  -m  -f human -df json-ld ./datagraphs/dataset-minimal.json-ld
Validation Report
Conforms: False
Results (1):
Constraint Violation in MinCountConstraintComponent (http://www.w3.org/ns/shacl#MinCountConstraintComponent):
        Severity: sh:Violation
        Source Shape: [ sh:maxCount Literal("1", datatype=xsd:integer) ; sh:minCount Literal("1", datatype=xsd:integer) ; sh:path <http://schema.org/citation> ]
        Focus Node: [ ]
        Result Path: <http://schema.org/citation>
 

pyshacl -s ./shapegraphs/reqrec.ttl  -m  -f human -df json-ld ./datagraphs/dataset-minimal.json-ld
Validation Report
Conforms: True
@ashleysommer

This comment has been minimized.

Copy link
Collaborator

@ashleysommer ashleysommer commented Mar 4, 2019

@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.

@fils

This comment has been minimized.

Copy link
Author

@fils fils commented Mar 5, 2019

@ashleysommer

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.

@ashleysommer

This comment has been minimized.

Copy link
Collaborator

@ashleysommer ashleysommer commented Mar 7, 2019

@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> .
@fils

This comment has been minimized.

Copy link
Author

@fils fils commented Mar 10, 2019

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.