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

Consider redesign of SPARQLModelAdapter #38

Closed
lu-pl opened this issue Aug 4, 2024 · 0 comments · Fixed by #64
Closed

Consider redesign of SPARQLModelAdapter #38

lu-pl opened this issue Aug 4, 2024 · 0 comments · Fixed by #64
Assignees
Labels
enhancement New feature or request

Comments

@lu-pl
Copy link
Contributor

lu-pl commented Aug 4, 2024

An alternative and arguably better interface for SPARQLModelAdaper would be something like this:

adapter = SPARQLModelAdapter(
    endpoint="https://query.wikidata.org/bigdata/namespace/wdq/sparql",
    query=query,
    model=model
)

# -> Iterable[_TModelInstance]
adapter.query()

# -> dict[str, Iterable[_TModelInstance]]                                                                            
adapter.query_group_by("x")
                                                   
# -> dict[str, Iterable[_TModelInstance]]/Iterable[_TModelInstance] ; len == 50 + page/size info
adapter.query_paginate(page=1, size=50, group_by="x")  

This simplifies usage and splits the responsibilities of SPARQLModelAdapter.__call__ into separate specialized methods.

A first step would be to transfer SPARQLModelAdapter.__call__ to SPARQLModelAdaper.query.

@lu-pl lu-pl added the help wanted Extra attention is needed label Aug 4, 2024
lu-pl added a commit that referenced this issue Aug 4, 2024
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.
lu-pl added a commit that referenced this issue Aug 4, 2024
Adapt basic SPARQLModelAdapter test according to redesigned
SPARQLModelAdapter interface.

Concerns: #38
lu-pl added a commit that referenced this issue Aug 4, 2024
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.
lu-pl added a commit that referenced this issue Aug 4, 2024
Adapt basic SPARQLModelAdapter test according to redesigned
SPARQLModelAdapter interface.

Concerns: #38
lu-pl added a commit that referenced this issue Aug 4, 2024
Adapt basic SPARQLModelAdapter test according to redesigned
SPARQLModelAdapter interface.

Concerns: #38
@lu-pl lu-pl self-assigned this Aug 4, 2024
@lu-pl lu-pl added discussion wanted and removed help wanted Extra attention is needed labels Aug 4, 2024
@lu-pl lu-pl added enhancement New feature or request and removed discussion wanted labels Aug 17, 2024
lu-pl added a commit that referenced this issue Aug 20, 2024
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.

Closes: #38.
lu-pl added a commit that referenced this issue Aug 20, 2024
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.

Closes: #38.
lu-pl added a commit that referenced this issue Aug 20, 2024
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.

Closes: #38.
lu-pl added a commit that referenced this issue Aug 20, 2024
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.

Closes: #38.
lu-pl added a commit that referenced this issue Aug 20, 2024
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.

Closes: #38.
@b1rger b1rger closed this as completed in 48b3e27 Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant