Skip to content

Add query to SPARQLwrapper strategy#269

Merged
torhaugl merged 12 commits intomasterfrom
sparql_query
Dec 9, 2024
Merged

Add query to SPARQLwrapper strategy#269
torhaugl merged 12 commits intomasterfrom
sparql_query

Conversation

@torhaugl
Copy link
Contributor

@torhaugl torhaugl commented Dec 5, 2024

Description

Add query to SPARQLwrapper backend. The result follows the same format as rdflib backend.

Can be tested with the following Python code if you have a SPARQL endpoint,

from tripper import SparqlwrapperStrategy
endpoint = "YOUR_ENDPOINT" #something like r"http://IP:PORT/repositories/TOPMAST"
ts = SparqlwrapperStrategy(endpoint)
res = ts.query(r"SELECT ?s ?p ?o WHERE { ?s ?p ?o . } LIMIT 1000")
print(res)

Type of change

  • Bug fix and code cleanup
  • New feature
  • Documentation update
  • Testing

Checklist for the reviewer

This checklist should be used as a help for the reviewer.

  • Is the change limited to one issue?
  • Does this PR close the issue?
  • Is the code easy to read and understand?
  • Do all new feature have an accompanying new test?
  • Has the documentation been updated as necessary?
  • Is the code properly tested?

@torhaugl torhaugl requested a review from jesper-friis December 5, 2024 13:10
@codecov
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.39%. Comparing base (f01f6ec) to head (740a2a0).
Report is 13 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #269      +/-   ##
==========================================
+ Coverage   79.30%   79.39%   +0.08%     
==========================================
  Files          18       18              
  Lines        1735     1742       +7     
==========================================
+ Hits         1376     1383       +7     
  Misses        359      359              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jesper-friis
Copy link
Contributor

Can be tested with the following Python code if you have a SPARQL endpoint,

from tripper import SparqlwrapperStrategy
endpoint = "YOUR_ENDPOINT" #something like r"http://IP:PORT/repositories/TOPMAST"
ts = SparqlwrapperStrategy(endpoint)
res = ts.query(r"SELECT ?s ?p ?o WHERE { ?s ?p ?o . } LIMIT 1000")
print(res)

The example should be rewritten as

from tripper import Triplestore
endpoint = "YOUR_ENDPOINT" #something like r"http://IP:PORT/repositories/TOPMAST"
ts = Triplestore(backend="sparqlwrapper", base_iri=endpoint)
res = ts.query(r"SELECT ?s ?p ?o WHERE { ?s ?p ?o . } LIMIT 20")
print(res)

Works great!

Copy link
Contributor

@jesper-friis jesper-friis left a comment

Choose a reason for hiding this comment

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

Works nicely. But please have a look at the comments.

@torhaugl
Copy link
Contributor Author

torhaugl commented Dec 6, 2024

I have added a test and adressed the comments. In addition I added a simple SPARQL query test which requires an internet connection. Please have a new look

@torhaugl torhaugl merged commit a3f69a0 into master Dec 9, 2024
@torhaugl torhaugl deleted the sparql_query branch December 9, 2024 09:33
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.

2 participants