Skip to content
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

Lupl/ungrouped pagination #44

Closed
wants to merge 6 commits into from
Closed

Lupl/ungrouped pagination #44

wants to merge 6 commits into from

Conversation

lu-pl
Copy link
Contributor

@lu-pl lu-pl commented Aug 4, 2024

Closes #43

lu-pl added 6 commits August 4, 2024 07:38
The redesign introduces major class API changes:

1. Initialization now takes the endpoint, query and model class directly, this simplifies
class usage and allows for better state retention in the instance.

2. functionality previously defined in
SPARQLModelAdapter.__call__ is transposed to SPARQLModelAdapter.query
which doesn't take any arguments but uses instance state to run a query
against an endpoint.

Considering planned grouping and pagination functionality,
responsibilites should be split into multiple specialized methods

Concerns: #38.
Adapt basic SPARQLModelAdapter test according to redesigned
SPARQLModelAdapter interface.

Concerns: #38
SPARQLModelAdapter.query_group_by allows to group model instances
retrevied from a query by a SPARQL binding.

Grouping must be possible based on SPARQL bindings, this is why coupling the
constructed model instance with the SPARQL bindings in SPARQLModelAdapter.query is important.

Also introduce a custom KeyError for indicating that a requested
binding is not available in the SPARQL projection for more specific testing.

Closes #40.
Implement basic tests including basic failure tests for SPARQLModelAdapter.query_group_by.

Also introduce a testing utils section including a module for
Hypothesis strategies.

Note: Care must be taken when using Hypothesis with tests that target a
remote service since Hypothesis generates input and runs a single test
many times which can lead to timeouts.
temporary_query_overrides allows to temporarily override the
queryString attribute in a SPARQLWrapper object.

The initial query is cached and returned on exit.
Implement SPARQLModelAdapter.query_paginate for ungrouped pagination.
For ungrouped pagination the internal query is temporarily modified
with page/offset and size/limit according to the page and size
parameters.

For FastAPI and pagination see https://lewoudar.medium.com/fastapi-and-pagination-d27ad52983a.

Closes #43.
@lu-pl lu-pl requested a review from b1rger August 4, 2024 16:13
@lu-pl lu-pl closed this Aug 12, 2024
@lu-pl lu-pl deleted the lupl/ungrouped_pagination branch October 18, 2024 04:30
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.

Implement SPARQLModelAdapter.query_paginate for ungrouped pagination
1 participant