Python SDK: Make Cohn feature backwards compatible#757
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR updates the SDK to support legacy COHN protobuf flows by introducing a unified ProtobufId identifier, adding support checks via a require_supported decorator, and enhancing the response parser and routing to handle unsupported protobuf responses gracefully.
- Introduce
ProtobufIdtype and update all parsers/commands to use it - Add
require_supporteddecorator andis_supportedchecks for features - Extend
BleRespBuilderand_route_responseto identify and route unsupported protobuf errors - Update tests and mocks to cover new unsupported-CoHN behavior
- Bump third-party dependency versions and enable debug logging for response parsing
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| demos/python/sdk_wireless_camera_control/thirdPartyDependencies.csv | Bump packaging to 25.0 and protobuf to 6.31.0 |
| demos/python/sdk_wireless_camera_control/tests/unit/test_wireless_gopro.py | Add unsupported protobuf operation test; update imports |
| demos/python/sdk_wireless_camera_control/tests/unit/test_responses.py | Add and adjust tests for unsupported protobuf responses |
| demos/python/sdk_wireless_camera_control/tests/unit/test_ble_commands.py | Import new ErrorCode and FeatureId for BLE command tests |
| demos/python/sdk_wireless_camera_control/tests/mocks.py | Extend mocks for protobuf and remove legacy BLE send override |
| demos/python/sdk_wireless_camera_control/open_gopro/util/logger.py | Enable DEBUG logging for open_gopro.parsers.response |
| demos/python/sdk_wireless_camera_control/open_gopro/parsers/response.py | Add validResponseProtobufIds and handle missing action IDs |
| demos/python/sdk_wireless_camera_control/open_gopro/models/types.py | Introduce ProtobufId and update ResponseType |
| demos/python/sdk_wireless_camera_control/open_gopro/models/constants/constants.py | Remove deprecated PROTOBUF_QUERY enum |
| demos/python/sdk_wireless_camera_control/open_gopro/gopro_wireless.py | Enhance _route_response to match unsupported protobuf errors |
| demos/python/sdk_wireless_camera_control/open_gopro/features/base_feature.py | Implement require_supported decorator and is_supported abstract property |
| demos/python/sdk_wireless_camera_control/open_gopro/features/cohn_feature.py | Add support tracking and guard methods with require_supported |
| demos/python/sdk_wireless_camera_control/open_gopro/features/streaming/stream_feature.py | Add is_supported property |
| demos/python/sdk_wireless_camera_control/open_gopro/features/access_point_feature.py | Add is_supported property |
| demos/python/sdk_wireless_camera_control/open_gopro/api/builders.py | Update BleProtoCommand to use ProtobufId |
| demos/python/sdk_wireless_camera_control/open_gopro/api/ble_commands.py | Update protobuf commands to use ProtobufId in additional_matching_ids |
Comments suppressed due to low confidence (8)
demos/python/sdk_wireless_camera_control/open_gopro/parsers/response.py:41
- [nitpick] Constant names should follow naming conventions (e.g., UPPER_SNAKE_CASE) or snake_case; consider renaming 'validResponseProtobufIds' to 'VALID_RESPONSE_PROTOBUF_IDS' or 'valid_response_protobuf_ids'.
validResponseProtobufIds: Final[list[tuple[FeatureId, ActionId]]] = [
demos/python/sdk_wireless_camera_control/tests/unit/test_wireless_gopro.py:10
- The import 'test' is unused or refers to a non-existent module; remove it to avoid import errors.
import test
demos/python/sdk_wireless_camera_control/tests/unit/test_wireless_gopro.py:166
- GoProResp is not imported in this test file, leading to a NameError; add 'from open_gopro.models import GoProResp' at the top.
mock_response = GoProResp(
demos/python/sdk_wireless_camera_control/tests/unit/test_wireless_gopro.py:168
- ErrorCode is not imported in this test file; add 'from open_gopro.models.constants.constants import ErrorCode'.
status=ErrorCode.INVALID_PARAM,
demos/python/sdk_wireless_camera_control/tests/unit/test_responses.py:36
- GoProUUID is not imported in this test, causing a NameError; add 'from open_gopro.models.constants import GoProUUID'.
identifier = BleRespBuilder.identify_response(GoProUUID.CQ_QUERY_RESP, response)
demos/python/sdk_wireless_camera_control/tests/unit/test_responses.py:55
- ErrorCode is not imported in this test file; add 'from open_gopro.models.constants.constants import ErrorCode'.
assert r.status == ErrorCode.INVALID_PARAM
demos/python/sdk_wireless_camera_control/tests/mocks.py:7
- [nitpick] The import 'Error' from csv is unused and can be removed to clean up unused imports.
from csv import Error
demos/python/sdk_wireless_camera_control/tests/mocks.py:9
- [nitpick] The import 'is_' from operator is unused and can be removed to clean up unused imports.
from operator import is_
|
need to do a final round of e2e testing for both H11 and H13 |
Pull Request Overview
This PR updates the SDK to support legacy COHN protobuf flows by introducing a unified
ProtobufIdidentifier, adding support checks via arequire_supporteddecorator, and enhancing the response parser and routing to handle unsupported protobuf responses gracefully.ProtobufIdtype and update all parsers/commands to use itrequire_supporteddecorator andis_supportedchecks for featuresBleRespBuilderand_route_responseto identify and route unsupported protobuf errorsShow a summary per file
packagingto 25.0 andprotobufto 6.31.0ErrorCodeandFeatureIdfor BLE command testsopen_gopro.parsers.responsevalidResponseProtobufIdsand handle missing action IDsProtobufIdand updateResponseTypePROTOBUF_QUERYenum_route_responseto match unsupported protobuf errorsrequire_supporteddecorator andis_supportedabstract propertyrequire_supportedis_supportedpropertyis_supportedpropertyBleProtoCommandto useProtobufIdProtobufIdinadditional_matching_ids