-
Notifications
You must be signed in to change notification settings - Fork 559
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
Sparql connector default graph #2761
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I am not of the maintainers but) this looks like a good functionality.
I would catch default_graph in __init__(..., default_graph=None, ...)
and save it as self.default_graph=default_graph
and later default to self.default_graph
instead of self.kwargs.get("default_graph")
. Because currently self.kwargs
is only used as params for request.
I would consider adding short docstring for SPARQLConnector.query
and.update
that default_graph
defaults to self.kwargs["default_graph"]
.
A test for this functionality might be a good idea as well.
Thanks for the feedback @WhiteGobo , I have little experience with the usage of In the matter of testing, though, I am not sure how to proceed there. Let me take a look at the current tests and try to figure it out on my own. I will report back here. |
This introduces `store_kwargs` which behaves similarly to `graph_kwargs` on the `RdfGraph` object, which will enable users to pass `headers` and other arguments to the underlying `SPARQLStore` object. I have also made a [PR in `rdflib` to support passing `default_graph`](RDFLib/rdflib#2761). Example usage: ```python from langchain_community.graphs import RdfGraph graph = RdfGraph( query_endpoint="http://localhost/sparql", standard="rdf", store_kwargs=dict( default_graph="http://example.com/mygraph" ) ) ``` <!--If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, hwchase17.--> --------- Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com> Co-authored-by: Bagatur <baskaryan@gmail.com>
@guizsantos I'm a maintainer. Just echoing @WhiteGobo: can you please add a short docstring? If you don't it won't be obvious at the function signature level that Oh yes: we will need a test. This is simple functionality but it's a rule of this repository that all new additions have a test. This change should be able to have a very simple test created for it that tests for 1. no default graph, |
Remove extra blank line that Ruff is complaining about.
@guizsantos would you be able to provide any updates for this PR now that the GitHub testing mechanism is working properly again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per previous comment about DocString
I just noticed one potentially concerning issue with this PR. The Docstring for Query and Update in the SPARQL Connector states:
So I was checking whether there might be a problem caused if the @guizsantos Are you able to fix up the docstring for both |
I've assigned myself to add the doc string that @guizsantos hasn't added before this gets merged. |
Summary of changes
This PR adds the functionality to pass the
default_graph
parameter from withinkwargs
. This will be particularly useful to the LangChainRdfGraph
object usage. I am pushing a PR there that will leverage the funcionality from this PR.Furthermore, the
default_graph
parameter which is passed directly to thequery
method has priority over thedefault_graph
parameter set fromkwargs
, which should be aligned with users expected behavior and offer backwards compatibilty.Finally, I am not sure an Issue should be created and linked or new tests should be introduced, this is actually my first ever PR on a public repository, so any guidance is appreciated.
Checklist
the same change.
./examples
.so maintainers can fix minor issues and keep your PR up to date.