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

odd behavior with SHACL inverse path #214

Open
1 task
fils opened this issue Dec 13, 2021 · 2 comments
Open
1 task

odd behavior with SHACL inverse path #214

fils opened this issue Dec 13, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@fils
Copy link
Contributor

fils commented Dec 13, 2021

I'm submitting a

  • [X ] bug report.
  • feature request.

Current Behaviour:

Expected Behaviour:

running pyshacl from the command results in this

(kglab) ➜  validation git:(master) ✗ pyshacl -s shapes/oih_checkDownload.ttl  -f human ./datagraphs/lipd.json
Validation Report
Conforms: False
Results (1):
Constraint Violation in MinCountConstraintComponent (http://www.w3.org/ns/shacl#MinCountConstraintComponent):
        Severity: shacl:Violation
        Source Shape: [ shacl:minCount Literal("1", datatype=xsd:integer) ; shacl:path [ shacl:inversePath rdf:type ] ]
        Focus Node: :Course
        Result Path: [ shacl:inversePath rdf:type ]
        Message: Less than 1 values on :Course->[ shacl:inversePath rdf:type ]

but the script simpleshacl.py in https://github.com/gleanerio/notebooks/tree/master/notebooks/validation when run generates

(kglab) ➜  validation git:(master) ✗ python simpleshacl.py                                                   
Usage of abort_on_error is deprecated. Use abort_on_first instead.
Traceback (most recent call last):
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1174, in uri_ref2
    ns = self._bindings[pfx]
KeyError: 'rdf'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "simpleshacl.py", line 25, in <module>
    conforms, report_graph, report_text = kg.validate(
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/kglab/kglab.py", line 1181, in validate
    g.parse(
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/graph.py", line 1261, in parse
    raise se
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/graph.py", line 1252, in parse
    parser.parse(source, self, **args)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1921, in parse
    p.loadStream(stream)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 438, in loadStream
    return self.loadBuf(stream.read())  # Not ideal
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 444, in loadBuf
    self.feed(buf)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 470, in feed
    i = self.directiveOrStatement(s, j)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 490, in directiveOrStatement
    j = self.statement(argstr, i)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 740, in statement
    j = self.property_list(argstr, i, r[0])
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1088, in property_list
    i = self.objectList(argstr, j, objs)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1132, in objectList
    i = self.object(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1418, in object
    j = self.subject(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 747, in subject
    return self.item(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 839, in item
    return self.path(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 846, in path
    j = self.nodeOrLiteral(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1446, in nodeOrLiteral
    j = self.node(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 919, in node
    i = self.property_list(argstr, j, subj)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1088, in property_list
    i = self.objectList(argstr, j, objs)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1132, in objectList
    i = self.object(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1418, in object
    j = self.subject(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 747, in subject
    return self.item(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 839, in item
    return self.path(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 846, in path
    j = self.nodeOrLiteral(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1446, in nodeOrLiteral
    j = self.node(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 919, in node
    i = self.property_list(argstr, j, subj)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1088, in property_list
    i = self.objectList(argstr, j, objs)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1132, in objectList
    i = self.object(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1418, in object
    j = self.subject(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 747, in subject
    return self.item(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 839, in item
    return self.path(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 846, in path
    j = self.nodeOrLiteral(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1446, in nodeOrLiteral
    j = self.node(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1050, in node
    j = self.uri_ref2(argstr, i, res)
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1182, in uri_ref2
    self.BadSyntax(argstr, i, 'Prefix "%s:" not bound' % (pfx))
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1653, in BadSyntax
    raise BadSyntax(self._thisDoc, self.lines, argstr, i, msg)
rdflib.plugins.parsers.notation3.BadSyntax: at line 10 of <>:
Bad syntax (Prefix "rdf:" not bound) at ^ in:
"...b':type ]" ;\n            shacl:resultPath [ shacl:inversePath '^b'rdf:type ] ;\n            shacl:resultSeverity shacl:Violatio'..."

You can also reference RDFLib/pySHACL#36 which may be related.

Steps to reproduce:

use the command above and the script simpleshacl.py in https://github.com/gleanerio/notebooks/tree/master/notebooks/validation environment file https://github.com/gleanerio/notebooks/blob/master/environment.yml

Environment:

  • python version 3.8.10
  • OS details Fedora 34

(kglab) ➜ validation git:(master) ✗ conda list | grep -i shacl
pyshacl 0.16.1 pyhd8ed1ab_0 conda-forge

@ceteri
Copy link
Collaborator

ceteri commented Dec 13, 2021

Good catch, thank you @fils !

I had an exchange with the lead for pySHACL yesterday. They'd had an error in their requirements.txt file that caused an installation conflict, even though they were trying to upgrade to support RDFlib v6.x

I work with the upgrades since that issue is resolved, and see if the version bumps resolve this

ceteri added a commit that referenced this issue Dec 13, 2021
upgrade OWL-RL and pySHACL to track RDFlib updates #214
@ceteri ceteri added the bug Something isn't working label Dec 13, 2021
@fils
Copy link
Contributor Author

fils commented Dec 14, 2021

@ceteri I'm still seeing this error after the update.

Traceback (most recent call last):
  File "/home/fils/.conda/envs/kglab/lib/python3.8/site-packages/rdflib/plugins/parsers/notation3.py", line 1174, in uri_ref2
    ns = self._bindings[pfx]
KeyError: 'rdf'

I can try and dive into it tomorrow. I have to leave today for family. I really want this one working since this pattern check is turning out to be really useful for my use cases. So I am motivated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants