RDFLib / rdflib

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
https://rdflib.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.15k stars 555 forks source link

SPARQL result parsing #2796

Open white-gecko opened 3 months ago

white-gecko commented 3 months ago

Summary of changes

Eventually, these changes could be superseded by a more flexible plugin system, that would distinguish between plugin name, supported format, and supported mime-type.

The changes should maintain backward compatibility.

But this API is now more flexible. The returnFormat for SPARQLConnector and SPARQLStore is now optional and None per default. Also the default Accept header lists all mime-types supported by parsers. Maybe this should be mentioned in the change notes.

Checklist

ashleysommer commented 2 months ago

@white-gecko this looks great, thanks. This addresses an issue I had only last month, I was trying to dynamically get the correct SPARQL result parser based on a mimetype, though the RDFLib plugin system, and I couldn't get it to work. Looks like now there is a way to do it.

ashleysommer commented 2 months ago

@white-gecko I've clearned up the commit pipeline, so we don't have Dependabot conflicts, mypy issues, black updates and ruff updates in the loop to prevent the proper testing of PRs. I've just re-ran the test suite on your PR, and it is failing one real test:

test_example[sparqlstore_example.py]

white-gecko commented 2 months ago

@ashleysommer I'm sorry, I don't really understand the test output, since it is successful for some runs but the output of the other test doesn't show the failing test.

Ok, I got it, these are failing:

    graph = Graph("SPARQLStore", identifier="http://dbpedia.org")
    graph.open("http://dbpedia.org/sparql")

    pop = graph.value(URIRef("http://dbpedia.org/resource/Berlin"), dbo.populationTotal)

This can be due to the content type, mimetype handling.

ashleysommer commented 2 months ago

Weirdly I'm seeing that exact same test_example[sparqlstore_example.py] failure on this unrelated PR: https://github.com/RDFLib/rdflib/pull/2818 Do you know what could be causing that?