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-9798 - ensure machine status is ready #831

Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
undo uv.lock changes
stuqdog committed Jan 28, 2025
commit 01058e5c9d7df48a2418aa2ad8fb13da5b713ea5
12 changes: 1 addition & 11 deletions docs/examples/_server.py
Original file line number Diff line number Diff line change
@@ -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()
7 changes: 7 additions & 0 deletions src/viam/robot/service.py
Original file line number Diff line number Diff line change
@@ -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))
Comment on lines +38 to +41
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanted to flag this, for the purposes of the documentation tests we need the service to have a GetMachineStatus implementation. But, I'm leaving it fairly barebones (it just always returns that we're running) because the issue we're trying to fix is one that exposes itself when using RDK as a server specifically.


async def ResourceNames(self, stream: Stream[ResourceNamesRequest, ResourceNamesResponse]) -> None:
request = await stream.recv_message()
assert request is not None