Skip to content

Conversation

@edmondchuc
Copy link
Contributor

Summary of changes

This PR introduces a httpx-based RDF4J Client that wraps the RDF4J REST API: https://rdf4j.org/documentation/reference/rest-api/.

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-level
  • Repository - manages an individual repository
    • NamespaceManager - manage a repository's namespace prefixes
    • GraphStoreManager - a repository's graph store protocol interface
    • Transaction - a transaction manager for a repository

Notes

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.0 in pyproject.toml as it's required by testcontainers. We can remove this upper bound once testcontainers relaxes this constraint in testcontainers/testcontainers-python#909.

Next steps

  • I will be working on an RDFLib Store implementation next that wraps the RDF4J Client in a separate PR.
  • Usage documentation and examples

Checklist

  • Checked that there aren't other open pull requests for
    the same change.
  • Checked that all tests and type checking passes.
  • If the change adds new features or changes the RDFLib public API:
    • Created an issue to discuss the change and get in-principle agreement.
    • Considered adding an example in ./examples.
  • If the change has a potential impact on users of this project:
    • Added or updated tests that fail without the change.
    • Updated relevant documentation to avoid inaccuracies.
    • Considered adding additional documentation.
  • Considered granting push permissions to the PR branch,
    so maintainers can fix minor issues and keep your PR up to date.

# Conflicts:
#	poetry.lock
…, add overwrite and get methods on Repository class and add tests for them
Also fixes a httpx limitation with key-only query params.
@nicholascar nicholascar self-requested a review November 7, 2025 03:09
namespace: str


class NamespaceManager:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you consider an alternate name here to ensure no confusion with RDFLib's NamespaceManager, or are you following naming suggested by the RDF4J API?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants