Skip to content

Commit 3857edf

Browse files
viambotgithub-actions[bot]
authored andcommitted
[WORKFLOW] AI update based on proto changes from commit 44bc963
1 parent 1ade187 commit 3857edf

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/viam/robot/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
GetOperationsResponse,
3131
GetVersionRequest,
3232
GetVersionResponse,
33+
JobStatus,
3334
LogRequest,
3435
ModuleModel,
3536
Operation,
@@ -890,7 +891,7 @@ async def get_version(self) -> GetVersionResponse:
890891

891892
async def get_machine_status(self) -> GetMachineStatusResponse:
892893
"""
893-
Get status information about the machine's resources and configuration.
894+
Get status information about the machine's resources, configuration, and job statuses.
894895
895896
::
896897
@@ -899,9 +900,10 @@ async def get_machine_status(self) -> GetMachineStatusResponse:
899900
resource_statuses = machine_status.resources
900901
cloud_metadata = machine_status.resources[0].cloud_metadata
901902
config_status = machine_status.config
903+
job_statuses = machine.get_machine_status().job_statuses
902904
903905
Returns:
904-
viam.proto.robot.GetMachineStatusResponse: current status of the machine (initializing or running), current status of the resources (List[ResourceStatus]) and the revision of the config of the machine.
906+
viam.proto.robot.GetMachineStatusResponse: current status of the machine (initializing or running), current status of the resources (List[ResourceStatus]), the revision of the config of the machine, and current job statuses (List[JobStatus]).
905907
906908
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
907909
"""

src/viam/robot/service.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from viam.errors import ViamGRPCError
99
from viam.proto.common import ResourceName
1010
from viam.proto.robot import (
11+
JobStatus,
1112
ResourceNamesRequest,
1213
ResourceNamesResponse,
1314
StopAllRequest,
@@ -67,3 +68,12 @@ async def StopAll(self, stream: Stream[StopAllRequest, StopAllResponse]) -> None
6768
if errors:
6869
raise ViamGRPCError(f'Failed to stop components named {", ".join(errors)}')
6970
await stream.send_message(StopAllResponse())
71+
72+
async def GetMachineStatus(self, stream: Stream[ResourceNamesRequest, ResourceNamesResponse]) -> None:
73+
request = await stream.recv_message()
74+
assert request is not None
75+
# Placeholder for retrieving actual job statuses.
76+
# This would typically involve retrieving actual job statuses from the robot's internal state or a job management system.
77+
job_statuses = []
78+
response = ResourceNamesResponse(resources=self._generate_metadata(), job_statuses=job_statuses)
79+
await stream.send_message(response)

tests/test_robot.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
GetOperationsResponse,
3232
GetVersionRequest,
3333
GetVersionResponse,
34+
JobStatus,
3435
Operation,
3536
ResourceNamesRequest,
3637
ResourceNamesResponse,
@@ -109,7 +110,8 @@
109110
name=ResourceName(namespace=RESOURCE_NAMESPACE_RDK, type=RESOURCE_TYPE_COMPONENT, subtype="arm", name="arm1"),
110111
state=ResourceStatus.State.STATE_READY,
111112
)
112-
]
113+
],
114+
job_statuses=[JobStatus(job_name="my_job", recent_successful_runs=[], recent_failed_runs=[])]
113115
)
114116

115117

@@ -367,6 +369,8 @@ async def test_get_machine_status(self, service: RobotService):
367369
async with await RobotClient.with_channel(channel, RobotClient.Options()) as client:
368370
statuses = await client.get_machine_status()
369371
assert statuses == GET_MACHINE_STATUS_RESPONSE
372+
assert len(statuses.job_statuses) == 1
373+
assert statuses.job_statuses[0].job_name == "my_job"
370374

371375
async def test_get_operations(self, service: RobotService):
372376
async with ChannelFor([service]) as channel:

0 commit comments

Comments
 (0)