Refactor sparql.query_df() to use query_raw#36
Conversation
…ng ValueError, dataset trimming and hanling of missing bindings
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #36 +/- ##
==========================================
- Coverage 90.20% 89.78% -0.43%
==========================================
Files 17 17
Lines 429 421 -8
==========================================
- Hits 387 378 -9
- Misses 42 43 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Refactors Ontodocker SPARQL DataFrame querying to reuse the existing HTTP-based query_raw() flow (instead of SPARQLWrapper), while tightening input validation and improving DataFrame column/binding handling.
Changes:
- Reworked
SparqlResource.query_df()to callquery_raw()and decode SPARQL results from JSON text. - Strengthened validation for
dataset,query, andcolumns, and ensured stable column ordering with consistent missing-binding handling. - Updated/expanded unit tests for invalid JSON, dataset trimming, missing bindings, and request construction (params/headers/auth).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
courier/services/ontodocker/sparql.py |
Refactors query_df() to fetch via query_raw() and adds stricter validation + JSON decoding error handling. |
courier/services/ontodocker/_compat.py |
Minor cleanup in make_dataframe() implementation/docstring while keeping missing bindings mapped to None. |
tests/unit/test_ontodocker_client.py |
Updates SPARQL resource tests to assert GET+params+Accept behavior, dataset trimming, invalid JSON handling, and token via session headers. |
tests/unit/services/ontodocker/test_compat.py |
Adjusts dataframe compatibility test to assert missing variables yield None consistently. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Coverage was lowered by 0928119 and e98d786, so I improved unit test coverage in 30205e7:
|
SparqlResource.query_df()to fetch JSON viaquery_raw()instead ofSPARQLWrapperquery_df()validation for dataset, query, and columnsDataFrameconversionquery_df()query_raw()