Giter Site home page Giter Site logo

SPARQLFunction support about pyshacl HOT 9 CLOSED

rdflib avatar rdflib commented on June 1, 2024
SPARQLFunction support

from pyshacl.

Comments (9)

James-Hudson3010 avatar James-Hudson3010 commented on June 1, 2024 1

I ran into the issue because I wanted to use the SHACL file at http://datashapes.org/schema to help validate schema.org data instances. I am not sure why or how it is using the SPARQLFunction feature, but assuming it is required for this purpose and considering that schema.org is mainstream, I am not sure if it can be defined as niche.

In any case, something to consider and perhaps keep an eye out for someone willing to implement it for pySHACL.

It would appear that the shaclvalidate tool at https://repo1.maven.org/maven2/org/topbraid/shacl/1.3.2/ implements the feature so there is a solid reference implementation out there which should help anyone who takes on the task.

from pyshacl.

ashleysommer avatar ashleysommer commented on June 1, 2024 1

I've had a one-person 13 hour codeathon tonight and fully implemented SHACLFunction and SPARQLFunction in pyshacl (as well as some other advanced spec features)
Can you please try pyshacl v0.13.0 and let me know if it fixes your problem?
Closed by cc3d291

from pyshacl.

ashleysommer avatar ashleysommer commented on June 1, 2024

The SPARQLFunction feature from the SHACL Advanced Spec is very complex, it would take a lot of effort to implement correctly in PySHACL. It seems to me to be a very niche feature that not many users would need or want.

However, I am happy to review and merge pull requests for features that developers want in PySHACL.

from pyshacl.

ashleysommer avatar ashleysommer commented on June 1, 2024

Hi @James-Hudson3010

The schema.org shacl file used to work fine with PySHACL. That was actually one of the SHACL files I used for testing PySHACL during development.

There must've been a recent update that added the use of SPARQLFunction. As far as I'm aware, the features from the SHACL Advanced Spec are not yet finalized, they may change before becoming a standard, and not considered stable for use in production validation systems, but that might be incorrect.

You can bypass this error if you turn off Advanced features in pyshacl (don't pass in the -a argument) this ignores all of the SHACL Advanced Spec features, and operates as if they don't exist in the SHACL file.

EDIT to add:
I didn't mean to imply that using pyshacl with the shema.org SHACL file is a niche thing. I know actually its the opposite. The vast majority of users of PySHACL are using it with shema.org shapes. In fact the main reason CSIRO sponsored the creation of PySHACL was to use it with shema.org shapes. What I meant was that the SPARQLFunction from the SHACL Advanced Spec is a niche feature and I don't know anybody who uses it or needs it implemented in PySHACL.

from pyshacl.

ashleysommer avatar ashleysommer commented on June 1, 2024

Seems this might be a PySHACL bug.
I've checked the whole file, and the Schema.org SHACL file doesn't use SPARQLFunction.

The SPARQLFunction advanced feature is triggered by:

  • A Shape that is of type sh:SPARQLFunction or
  • A shape with sh:parameter or
  • A shape with sh:returnType

There are none of those in the Schema.org SHACL file. I'll have to dig a bit further to find out whats going on.

from pyshacl.

ashleysommer avatar ashleysommer commented on June 1, 2024

@James-Hudson3010
I cannot reproduce this bug. I've loaded the schema.ttl file from Schema.org into PySHACL (with advanced mode turned on) and used it to validate several datafiles, and it works normally. It does not trigger the SPARQLFunction is not yet supported error because sh:SPARQLFunction is not used in that file.

from pyshacl.

ashleysommer avatar ashleysommer commented on June 1, 2024

Update:
I found it. SPARQLFunction is used in http://datashapes.org/dash.ttl that is imported by schema.ttl.
I had imports turned off, that's why I didn't see the error.
If you turn off imports, the SHACL file will not pull in dash.ttl, so it will not throw this error.

Side note: Dash is another extension to SHACL, which is above and beyond the SHACL Advanced Spec, there a things like dash:Scripts and dash:Actions which can execute Javascript code on the dataset, and looks like there are a couple of helper functions which are Shapes that use SPARQLFunction to execute SPARQL on the dataset.

I'm thinking about what will be the best way forward here. Blocking the import of dash.ttl is one way, but is probably too heavy handed. Perhaps for now simply ignoring any shapes from the <http://datashapes.org/dash> ontology might work, at least until PySHACL gets enough advanced features in order to take advantage of DASH.

from pyshacl.

James-Hudson3010 avatar James-Hudson3010 commented on June 1, 2024

I will check it out when I get the chance. Thank you.

from pyshacl.

James-Hudson3010 avatar James-Hudson3010 commented on June 1, 2024

Confirmed. Works for me now.

from pyshacl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.