Decouple TDK API from underlying REST API #333
Merged
Merged
Conversation
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
Redocly preview |
pasin
approved these changes
Dec 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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