-
Notifications
You must be signed in to change notification settings - Fork 579
feat: RDF4J Client #3306
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
feat: RDF4J Client #3306
Conversation
…ementation Also set up and add tests
# Conflicts: # poetry.lock
…, add overwrite and get methods on Repository class and add tests for them
…d some docstring content
… object of Repository.get() method
Also fixes a httpx limitation with key-only query params.
…ons as well" This reverts commit 323f303.
…ec. Update tests to skip if httpx is not available
|
Adding a comment here to remind myself to add |
* fix: handle graph_name when it's a str * feat: wip RDF4JStore Implements: - init/open - close - add - addN - contexts - add_graph - remove_graph - __len__ * feat: RDF4J Store now supports handling namespaces and prefixes * feat: RDF4J Store triples and quads querying * feat: ensure no bnodes are used to cross document/query boundaries * chore: formatting * test: improve e2e test speed by reusing the same container and cleaning up the repo between each tests * feat: add RDF4JStore remove * feat: add RDF4JStore triples_choices tests * feat: add RDF4JStore SPARQL query and update tests * chore: fix mypy issues * test: error handling on client fixture * test: mark testcontainer tests and put test imports behind the has_httpx flag * build: remove upper python bound, bump testcontainers, and revert back to stable v7 poetry.lock * test: put testcontainer tests behind a flag for unsupported python versions * test: install rdf4j extras for python 3.9 and above * ci: skip testcontainer tests on non-linux runners
|
Merging the RDF4J store PR #3316 should now fix the tests here. Reminding myself here that I still need to rename the NamespaceManager class. |
|
Note that the end-to-end tests using testcontainers only run on the Linux runners in GitHub Actions. Additionally, testcontainers is only installed on python 3.9+. |
Summary of changes
This PR introduces a httpx-based RDF4J Client that wraps the RDF4J REST API and implements an RDF4J Store (#3316).
Where possible, it provides tight integration with RDFLib by returning RDFLib data objects for graphs, datasets, and SPARQL results.
Majority of the code is in
rdflib.contrib.rdf4j.client. The codebase is covered by unit tests (with mocks) and end-to-end test with testcontainers, which spins up real GraphDB instances. I've tried to document what I can with docstrings, but I will add user-facing documentation soon.The main classes to note:
RDF4JClient- the main entrypoint to using this package.RepositoryManager- manage repositories at the server-levelRepository- manages an individual repositoryNamespaceManager- manage a repository's namespace prefixesGraphStoreManager- a repository's graph store protocol interfaceTransaction- a transaction manager for a repositoryNotes
A small bit of GraphDB specific code is included in the PR but please ignore it for now. This is incomplete and only here to showcase how we'd implement some GraphDB specific handling on top of RDF4J. This will be a separate piece of work in a separate PR.
I had to add in the python version upper bound<4.0inpyproject.tomlas it's required by testcontainers. We can remove this upper bound once testcontainers relaxes this constraint in testcontainers/testcontainers-python#909.This is now resolved with the release of python testcontainers 4.13.3.
Next steps
I will be working on an RDFLib Store implementation next that wraps the RDF4J Client in a separate PR.Checklist
the same change.
./examples.so maintainers can fix minor issues and keep your PR up to date.