Skip to content

Decouple TDK API from underlying REST API #333

Merged
borrrden merged 3 commits into
mainfrom
fix/api_version_decoupling
Dec 9, 2025
Merged

Decouple TDK API from underlying REST API #333
borrrden merged 3 commits into
mainfrom
fix/api_version_decoupling

Conversation

@borrrden
Copy link
Copy Markdown
Member

@borrrden borrrden commented Dec 9, 2025

Eliminates the inherent dependencies on v1 of the API for the test facing API and introduces a request and response registry to detemine how to serialize messages

This is a large PR so I will summarize each file (some grouped together)

test_new_session.py -> API signature change for the new_session method (not used by tests directly, except for this one which tests the new_session endpoint itself, so it's ok to change it)

database.py / listener.py / multipeer_replicator.py / replicator.py / testserver.py -> Remove all v1 imports and replace with interfaces. Make use of the new factory method for creating a request.

v1/requests.py -> Remove versions from the payload and put them directly in the request. The body does not need to know its version anymore.

v1/responses.py -> Add a decorator to register responses based on request types. There is a sanity check in v1/requests.py now which makes sure that every request has a registered response so things can fail early. Remove versions from the responses as well. The version will be verified on receipt and not much used otherwise.

v2/requests.py / v2/reqponses.py -> API v2 messages

cbltest/init.py -> Before the suite run, ask each test server what API version it is and error if they don't match each other.

request_types.py -> Add interfaces for methods on a request body. Remove request body base class and just use JSONSerializable. Move some common types out of v1 and into here.

requests.py -> Add in decorators to auto register all requests and bodies for given versions of the API. Most are unchanged in v2, so they are registered in both v1 and v2 in the v1 requests file. Some of the bodies which now take URLs in place of names (dataset / blob) so there is some hacking for v1 to reverse that. Delay setting the request factory version because it won't be known until the end of some async processing. Allow it to be set only once, and have it then import all needed requests and responses. Create a factory method that generates requests rather than using versioned ones directly. This makes things more flexible by far but it erases direct signature inspection, unfortunately. Missing arguments will quickly error, though, so it will be visible.

requests_transport.py -> Use new response registry to generate a response rather than using versioned ones directly

response_types.py -> Add some response interface methods so that either version can be worked with even if the version is not known at runtime

responses.py -> Remove version from base class of response

version.py -> Bump TDK version and add new available api version 2

Eliminates the inherent dependencies on v1 of the API for the test facing API and introduces a request and response registry to detemine how to serialize messages

This is a large PR so I will summarize each file (some grouped together)

test_new_session.py -> API signature change for the new_session method (not used by tests directly, except for this one which tests the new_session endpoint itself, so it's ok to change it)

database.py / listener.py / multipeer_replicator.py / replicator.py / testserver.py -> Remove all v1 imports and replace with interfaces.  Make use of the new factory method for creating a request.

testserver.py -> Add in dataset_version argument for construction so that a new config.py is not needed just for changing dataset versions

cblpytest_fixture.py -> Add a new pytest argument, --dataset-version, which will set the global dataset version to be used in the test run (if not overriden in config.json)

v1/requests.py -> Remove versions from the payload and put them directly in the request.  The body does not need to know its version anymore.

v1/responses.py -> Add a decorator to register responses based on request types.  There is a sanity check in v1/requests.py now which makes sure that every request has a registered response so things can fail early.  Remove versions from the responses as well.  The version will be verified on receipt and not much used otherwise.

v2/requests.py / v2/reqponses.py -> API v2 messages

cbltest/__init__.py -> Before the suite run, ask each test server what API version it is and error if they don't match each other.

configparser.py -> remove api_version from config.json and make dataset_version optional for test_servers

request_types.py -> Add interfaces for methods on a request body.  Remove request body base class and just use JSONSerializable.  Move some common types out of v1 and into here.

requests.py -> Add in decorators to auto register all requests and bodies for given versions of the API.  Most are unchanged in v2, so they are registered in both v1 and v2 in the v1 requests file.  Some of the bodies which now take URLs in place of names (dataset / blob) so there is some hacking for v1 to reverse that.  Delay setting the request factory version because it won't be known until the end of some async processing.  Allow it to be set only once, and have it then import all needed requests and responses.  Create a factory method that generates requests rather than using versioned ones directly.  This makes things more flexible by far but it erases direct signature inspection, unfortunately.  Missing arguments will quickly error, though, so it will be visible.

requests_transport.py -> Use new response registry to generate a response rather than using versioned ones directly

response_types.py -> Add some response interface methods so that either version can be worked with even if the version is not known at runtime

responses.py -> Remove version from base class of response

version.py -> Bump TDK version and add new available api version 2

setup_topology.py -> Make dataset_version optional

start_backend.py -> Only emit dataset_version if present in input
Remove ability to handle multiple versions, it is not going to be helpful in the future since TDK client always comes from main
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 9, 2025

Redocly preview

API

@borrrden borrrden requested a review from pasin December 9, 2025 00:34
@borrrden borrrden merged commit 137c880 into main Dec 9, 2025
7 checks passed
@borrrden borrrden deleted the fix/api_version_decoupling branch December 9, 2025 02:44
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