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

SPARQLUpdateStore does not work with GraphDB endpoints #1251

Open
robertbbb opened this issue Feb 8, 2021 · 6 comments
Open

SPARQLUpdateStore does not work with GraphDB endpoints #1251

robertbbb opened this issue Feb 8, 2021 · 6 comments
Labels
bug Something isn't working SPARQL

Comments

@robertbbb
Copy link

I'm regularly using GraphDB with RDF libraries from a variety of languages, but could never make it with rdflib and hoped this will be solved in the major update that is 5.0.0. From what I was able to gather this is an issue of its SPARQLUpdateStore (which also happens to be weakly documented). The following is a piece of Python that attempts to write a graph into a GraphDB store.

from rdflib import Graph, URIRef
from rdflib.plugins.stores import sparqlstore
g=Graph(identifier=URIRef("http://example.org/mygraph"))
mystring="@prefix : <http://example.org/>. :John :livesIn :Vienna."
g.parse(data=mystring,format="turtle")
readURL="http://localhost:7200/repositories/myrepo"
writeURL="http://localhost:7200/repositories/myrepo/statements"
mystore=sparqlstore.SPARQLUpdateStore()
mystore.open((readURL,writeURL))
mystore.add_graph(g)

Not sure if I'm doing something wrong or if there's a problem with rdflib, but what I get is:

requests.exceptions.HTTPError: 415 Client Error: for url: http://localhost:7200/repositories/myrepo/statements

@nicholascar nicholascar added the bug Something isn't working label Feb 8, 2021
@nicholascar
Copy link
Member

I can confirm that the code above with the following lines to add triples instead of add_graph works fine:

mystore.add((
    URIRef("http://example.org/John"),
    URIRef("http://example.org/livesIn"),
    URIRef("http://example.org/Vienna"),
))

I'll look into add_graph next.

@nicholascar
Copy link
Member

Another follow-up: I don't get a 415 error with your code above, instead I get no failure but also not graph addition. If I mangle the .../statements URI then I get a 415.

Also, when I look in the GraphDB query log after running the original code, i.e. add_graph, I see:

[INFO ] 2021-02-08 21:10:42,973 [repositories/myrepo | c.o.t.m.MonitorRepositoryConnection] Incoming update:
CREATE GRAPH <http://example.org/mygraph>

So it looks to me like rdflib is passing the correct create graph message to GraphDB but GraphDB doesn't seem to be creating the graph correctly and there's no indication that the triples of the graph are being sent over.

Wehn I run CREATE GRAPH <http://example.org/mygraph> directly in GraphDB's owl SPARQL UI, I get the message _The number of statements did not change. Update took 0.1s, minutes ago. _ and no indication that a graph has actually been created (i.e. it's not listed), so it appears:

  1. GraphDB doesn't create empty graphs with CREATE GRAPH <...>
  2. rdflib with add_graph is sending a CREATE GRAPH <...> command but no data

@robertbbb
Copy link
Author

With mystore.add(...) I get the exact same 415 error. In GraphDB's log it shows the following (for both add and add_graph):

[INFO ] 2021-02-08 13:36:27,926 [repositories/myrepo | c.o.f.s.GraphDBProtocolExceptionResolver] Client sent bad request ( 415)
org.eclipse.rdf4j.http.server.ClientHTTPException: Unsupported MIME type: null

What versions did you use to run add() successfully? My setup is:

GraphDB 9.4.1
Python 3.9.1-64bit
rdflib 5.0.0 (as installed by SPARQLWrapper, not directly)

@nicholascar
Copy link
Member

GraphDB 8.10
Python 3.7
RDFLib 5.0.0

Definitely something odd there as I'm really not getting 415 errors.

I might have to look into the SPARQLUpdateStore code to see what headers are emitted.

@nicholascar
Copy link
Member

I think I'm seeing the same behavior with Jena/Fuseki too. add works fine but add_graph gives no error but doesn't seem to do anything

@jgonggrijp
Copy link

I suspect I'm seeing a flavor of this problem with insert and delete updates in Fuseki. I'm working with rdflib 5.0.0, too. No errors are thrown. When I do a delete { ?s ?p ?o } where { ?s ?p ?o } update on a non-empty graph, rdflib's local view of the graph is emptied, but when checking back on the Fuseki side, it turns out that the graph still contains all the triples from before. Similar effective-yet-not-effective effects are seen with insert.

I'm seeing this when calling rdflib.Graph.update on a named graph that has a SPARQLUpdateStore referincing a Fuseki server as its underlying store.

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

No branches or pull requests

4 participants