Closed nicholascar closed 2 years ago
Hi @nicholascar quick question. Could you share the endpoint where this issue is raised? It this is not possible, could you tell us the version of fuseki? Thanks!
Apologies for the delay in responding to this.
The Apache Jena Fuseki instance we are using is Version 3.10.0.
If you email me at Alex(dot)Ip(at)ga(dot)gov(dot)au, I can send you through a working endpoint and some credentials to access it.
Cheers,
Alex
Thanks @alex-ip !
From my notes (available at the top of the code of Wrapper.py), "turtle" is not a valid alias for the output for Apache Jena Fuseki2.
In this case, maybe you can try setOnlyConneg() method.
I have tested it with an open endpoint of Apache Jena Fuseki (version 3.6.0) and it looks like it is working. Please, find the example below.
from SPARQLWrapper import SPARQLWrapper, TURTLE
from rdflib import Graph
sparql = SPARQLWrapper("http://agrovoc.uniroma2.it:3030/agrovoc/sparql") # Fuseki 3.6.0 (Fuseki2)
sparql.setQuery("""
DESCRIBE <http://aims.fao.org/aos/agrovoc/c_aca7ac6d>
""")
sparql.setReturnFormat(TURTLE)
sparql.setOnlyConneg(True)
results = sparql.query().convert()
g = Graph()
g.parse(data=results, format="turtle")
print(g.serialize(format='turtle'))
Thanks, @dayures!
It looks like the setOnlyConneg fix only "kind of" worked with Apache Jena Fuseki version 3.10.0. It works for turtle, json-ld and rdf+xml, but requesting "n3" for a describe query returns a turtle response.
At least it doesn't error out.
Cheers,
Alex
@alex-ip n3 pretty much is Turtle. What we’re you expecting to get from using n3 other than Turtle?
If this is ok, can the Issue close?
G'day @nicholascar - I reckon that returning turtle when n3 is specified is probably not ideal behaviour. We are trying to offer RDF content from Jena-Fuseki triple-store in multiple formats, so I would prefer to obtain the result of a "describe" query in the required format rather than having to convert it client-side. Cheers, Alex
@alex-ip Maybe it is an issue in Fuseki.
Using a testing app for REST request (Advanced REST Cliente), I queried a Fuseki 3.6.0 endpoint, using GET verb, a DESCRIBE query and the Accept
header value text/rdf+n3;application/n3;text/n3
http://agrovoc.uniroma2.it:3030/agrovoc/sparql?query=DESCRIBE <http://aims.fao.org/aos/agrovoc/c_aca7ac6d>
The response header was content-type: text/turtle; charset=utf-8
N3 is not a standard syntax.
Why is SPARQLWrapper sending triplestore-specific URL parameters such as output
and results
? Content negotiation should be the default mode, as it is the only standard one.
sparql.setOnlyConneg(True)
should be the default setting... >:(
This issue is now resolved, perhaps due to Fuseki updates, becuase this code now works (with an updated AGROVOC SPARQL endpoint):
from rdflib import Graph
sparql = SPARQLWrapper("https://agrovoc.fao.org/sparql") # Fuseki 3.6.0 (Fuseki2)
sparql.setQuery("""
DESCRIBE <http://aims.fao.org/aos/agrovoc/c_aca7ac6d>
""")
sparql.setReturnFormat(TURTLE)
sparql.setOnlyConneg(True)
results = sparql.query().convert()
g = Graph()
g.parse(data=results, format="turtle")
print(g.serialize())
sparql.setOnlyConneg(True)
must be included.
Reported by @alex-ip:
Fuseki won't accept 'turtle' as an output format and fails - returns 500 - if it is set. Is this a known bug?
A quick hack fix to use text/turtle instead of turtle is presented below.
For file https://github.com/RDFLib/sparqlwrapper/blob/master/SPARQLWrapper/Wrapper.py, function
_query()