diff --git a/docs/examples/_server.py b/docs/examples/_server.py index 396105988..a44084680 100644 --- a/docs/examples/_server.py +++ b/docs/examples/_server.py @@ -6,11 +6,6 @@ from grpclib.server import Server, Stream from grpclib.utils import graceful_exit -from viam.proto.robot import ( - UnimplementedRobotServiceBase, - GetMachineStatusRequest, - GetMachineStatusResponse -) from viam.app.data_client import DataClient from viam.proto.app import ( AddRoleRequest, @@ -600,13 +595,8 @@ async def GetRegistryItem(self, stream: Stream[GetRegistryItemRequest, GetRegist raise NotImplementedError() -class MockRobot(UnimplementedRobotServiceBase): - async def GetMachineStatus(self, stream: Stream[GetMachineStatusRequest, GetMachineStatusResponse]) -> None: - await stream.send_message(GetMachineStatusResponse(state: GetMachineStatusResponse.STATE_RUNNING)) - - async def main(*, host: str = "127.0.0.1", port: int = 9092) -> None: - server = Server([MockData(), MockDataSync(), MockApp(), MockRobot()]) + server = Server([MockData(), MockDataSync(), MockApp()]) with graceful_exit([server]): await server.start(host, port) await server.wait_closed() diff --git a/src/viam/robot/service.py b/src/viam/robot/service.py index 715cbe11f..74d7cd80b 100644 --- a/src/viam/robot/service.py +++ b/src/viam/robot/service.py @@ -8,6 +8,8 @@ from viam.errors import ViamGRPCError from viam.proto.common import ResourceName from viam.proto.robot import ( + GetMachineStatusRequest, + GetMachineStatusResponse, ResourceNamesRequest, ResourceNamesResponse, StopAllRequest, @@ -33,6 +35,11 @@ def _generate_metadata(self) -> List[ResourceName]: return list(md) + async def GetMachineStatus(self, stream: Stream[GetMachineStatusRequest, GetMachineStatusResponse]) -> None: + request = await stream.recv_message() + assert request is not None + await stream.send_message(GetMachineStatusResponse(state=GetMachineStatusResponse.STATE_RUNNING)) + async def ResourceNames(self, stream: Stream[ResourceNamesRequest, ResourceNamesResponse]) -> None: request = await stream.recv_message() assert request is not None