Conversation
WhiteGobo
left a comment
There was a problem hiding this comment.
(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? |
nicholascar
left a comment
There was a problem hiding this comment.
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_graphparameter from withinkwargs. This will be particularly useful to the LangChainRdfGraphobject usage. I am pushing a PR there that will leverage the funcionality from this PR.Furthermore, the
default_graphparameter which is passed directly to thequerymethod has priority over thedefault_graphparameter 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.