Skip to content

Commit

Permalink
Fix get_geometries signature (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheukt authored Aug 24, 2023
1 parent 51eb290 commit 0fc9542
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/examples/my_cool_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async def stop(self, extra: Optional[Dict[str, Any]] = None, **kwargs):
async def is_moving(self) -> bool:
return not self.is_stopped

async def get_geometries(self) -> List[Geometry]:
async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) -> List[Geometry]:
return self.geometries

async def get_kinematics(self, extra: Optional[Dict[str, Any]] = None, **kwargs) -> Tuple[KinematicsFileFormat.ValueType, bytes]:
Expand Down
2 changes: 1 addition & 1 deletion examples/complex_module/src/arm/my_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def stop(self, extra: Optional[Dict[str, Any]] = None, **kwargs):
async def is_moving(self) -> bool:
return not self.is_stopped

async def get_geometries(self) -> List[Geometry]:
async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) -> List[Geometry]:
return self.geometries

async def get_kinematics(self, extra: Optional[Dict[str, Any]] = None, **kwargs) -> Tuple[KinematicsFileFormat.ValueType, bytes]:
Expand Down
4 changes: 2 additions & 2 deletions src/viam/components/component_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import abc
from typing import TYPE_CHECKING, ClassVar, List, Mapping, Optional, SupportsBytes, SupportsFloat, Union, cast
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Mapping, Optional, SupportsBytes, SupportsFloat, Union, cast

from typing_extensions import Self

Expand Down Expand Up @@ -43,7 +43,7 @@ def from_robot(cls, robot: "RobotClient", name: str) -> Self:
async def do_command(self, command: Mapping[str, ValueTypes], *, timeout: Optional[float] = None, **kwargs) -> Mapping[str, ValueTypes]:
raise NotImplementedError()

async def get_geometries(self) -> List[Geometry]:
async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) -> List[Geometry]:
"""
Get all geometries associated with the Component, in their current configuration, in the frame of the Component.
Expand Down
5 changes: 3 additions & 2 deletions src/viam/resource/types.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import re
import sys
from typing import TYPE_CHECKING, Callable, ClassVar, Mapping, Optional, Protocol, Sequence, runtime_checkable
from typing import TYPE_CHECKING, Callable, ClassVar, Mapping, Protocol, Sequence, runtime_checkable

if sys.version_info >= (3, 10):
from typing import TypeAlias
else:
from typing_extensions import TypeAlias

from grpclib.server import Stream
from typing_extensions import Self

from viam.proto.app.robot import ComponentConfig
Expand Down Expand Up @@ -204,5 +205,5 @@ def resource_name_from_string(string: str) -> ResourceName:
class SupportsGetGeometries(Protocol):
"""The SupportsGetGeometries protocol defines the requirements for a resource to call get_geometries."""

async def GetGeometries(self, request: GetGeometriesRequest, timeout: Optional[float] = None) -> GetGeometriesResponse:
async def GetGeometries(self, stream: Stream[GetGeometriesRequest, GetGeometriesResponse]) -> None:
...

0 comments on commit 0fc9542

Please sign in to comment.