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

[RSDK-9631] Add deprecation warnings to DiscoverComponents #818

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/viam/proto/robot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
CancelOperationRequest,
CancelOperationResponse,
ConfigStatus,
DiscoverComponentsRequest,
DiscoverComponentsResponse,
DiscoverComponentsRequest, # deprecated, remove on march 10th
DiscoverComponentsResponse, # deprecated, remove on march 10th
Discovery,
DiscoveryQuery,
FrameSystemConfig,
Expand Down Expand Up @@ -73,8 +73,8 @@
"CancelOperationRequest",
"CancelOperationResponse",
"ConfigStatus",
"DiscoverComponentsRequest",
"DiscoverComponentsResponse",
"DiscoverComponentsRequest", # deprecated, remove on march 10th
"DiscoverComponentsResponse", # deprecated, remove on march 10th
"Discovery",
"DiscoveryQuery",
"FrameSystemConfig",
Expand Down
7 changes: 7 additions & 0 deletions src/viam/robot/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import sys
import warnings
from dataclasses import dataclass
from datetime import datetime
from threading import RLock
Expand Down Expand Up @@ -732,6 +733,7 @@ async def discover_components(
queries: List[DiscoveryQuery],
) -> List[Discovery]:
"""
Deprecated: v0.38.0, use the Discovery Service APIs instead.
Get a list of discovered potential component configurations, for example listing different supported resolutions. Currently only works for some cameras.
Returns module names for modules.

Expand Down Expand Up @@ -759,6 +761,11 @@ async def discover_components(
"""
request = DiscoverComponentsRequest(queries=queries)
response: DiscoverComponentsResponse = await self._client.DiscoverComponents(request)
warnings.warn(
"RobotClient.discover_components is deprecated. It will be removed on March 10 2025. Use the DiscoveryService APIs instead.",
DeprecationWarning, stacklevel=2)
LOGGER.warning(
"RobotClient.discover_components is deprecated. It will be removed on March 10 2025. Use the DiscoveryService APIs instead.")
return list(response.discovery)

############
Expand Down
5 changes: 0 additions & 5 deletions tests/mocks/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
BlockForOperationResponse,
CancelOperationRequest,
CancelOperationResponse,
DiscoverComponentsRequest,
DiscoverComponentsResponse,
FrameSystemConfigRequest,
FrameSystemConfigResponse,
GetCloudMetadataRequest,
Expand Down Expand Up @@ -100,9 +98,6 @@ async def FrameSystemConfig(self, stream: Stream[FrameSystemConfigRequest, Frame
async def TransformPose(self, stream: Stream[TransformPoseRequest, TransformPoseResponse]) -> None:
raise MethodNotImplementedError("TransformPose").grpc_error

async def DiscoverComponents(self, stream: Stream[DiscoverComponentsRequest, DiscoverComponentsResponse]) -> None:
raise MethodNotImplementedError("DiscoverComponents").grpc_error

async def StopAll(self, stream: Stream[StopAllRequest, StopAllResponse]) -> None:
raise MethodNotImplementedError("StopAll").grpc_error

Expand Down
16 changes: 0 additions & 16 deletions tests/test_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
BlockForOperationResponse,
CancelOperationRequest,
CancelOperationResponse,
DiscoverComponentsRequest,
DiscoverComponentsResponse,
Discovery,
DiscoveryQuery,
FrameSystemConfig,
Expand Down Expand Up @@ -168,12 +166,6 @@ async def TransformPose(stream: Stream[TransformPoseRequest, TransformPoseRespon
response = TransformPoseResponse(pose=TRANSFORM_RESPONSE)
await stream.send_message(response)

async def DiscoverComponents(stream: Stream[DiscoverComponentsRequest, DiscoverComponentsResponse]) -> None:
request = await stream.recv_message()
assert request is not None
response = DiscoverComponentsResponse(discovery=DISCOVERY_RESPONSE)
await stream.send_message(response)

async def GetOperations(stream: Stream[GetOperationsRequest, GetOperationsResponse]) -> None:
request = await stream.recv_message()
assert request is not None
Expand Down Expand Up @@ -205,7 +197,6 @@ async def Shutdown(stream: Stream[ShutdownRequest, ShutdownResponse]) -> None:
service = RobotService(manager)
service.FrameSystemConfig = Config
service.TransformPose = TransformPose
service.DiscoverComponents = DiscoverComponents
service.GetOperations = GetOperations
service.GetCloudMetadata = GetCloudMetadata
service.Shutdown = Shutdown
Expand Down Expand Up @@ -374,13 +365,6 @@ async def test_transform_pose(self, service: RobotService):
assert pose == TRANSFORM_RESPONSE
await client.close()

async def test_discover_components(self, service: RobotService):
async with ChannelFor([service]) as channel:
client = await RobotClient.with_channel(channel, RobotClient.Options())
discoveries = await client.discover_components([DISCOVERY_QUERY])
assert discoveries == DISCOVERY_RESPONSE
await client.close()

async def test_get_cloud_metadata(self, service: RobotService):
async with ChannelFor([service]) as channel:
client = await RobotClient.with_channel(channel, RobotClient.Options())
Expand Down
Loading