Skip to content

Commit

Permalink
[RSDK-4561] Remove unused check (viamrobotics#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
njooma authored May 22, 2024
1 parent e03c710 commit cc1e715
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 34 deletions.
6 changes: 0 additions & 6 deletions src/viam/robot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import viam
from viam import logging
from viam.components.component_base import ComponentBase
from viam.components.movement_sensor import MovementSensor
from viam.components.sensor import Sensor
from viam.errors import ResourceNotFoundError
from viam.proto.common import LogEntry, PoseInFrame, ResourceName, Transform
from viam.proto.robot import (
Expand Down Expand Up @@ -305,10 +303,6 @@ async def refresh(self):
if rname.subtype == "remote":
continue

# If the resource is a MovementSensor, DO NOT include Sensor as well (it will get added via MovementSensor)
if rname.subtype == Sensor.SUBTYPE.resource_subtype and MovementSensor.get_resource_name(rname.name) in resource_names:
continue

await self._create_or_reset_client(rname)

for rname in self.resource_names:
Expand Down
2 changes: 1 addition & 1 deletion src/viam/services/vision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from viam.services.vision.service import VisionRPCService

from .client import Classification, Detection, VisionClient
from .vision import Vision, CaptureAllResult
from .vision import CaptureAllResult, Vision

__all__ = [
"CaptureAllResult",
Expand Down
20 changes: 10 additions & 10 deletions src/viam/services/vision/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from viam.resource.rpc_client_base import ReconfigurableResourceRPCClientBase
from viam.utils import ValueTypes, dict_to_struct, struct_to_dict

from .vision import Vision, CaptureAllResult
from .vision import CaptureAllResult, Vision


class VisionClient(Vision, ReconfigurableResourceRPCClientBase):
Expand Down Expand Up @@ -57,14 +57,14 @@ async def capture_all_from_camera(
if extra is None:
extra = {}
request = CaptureAllFromCameraRequest(
name=self.name,
camera_name=camera_name,
return_image=return_image,
return_classifications=return_classifications,
return_detections=return_detections,
return_object_point_clouds=return_object_point_clouds,
extra=dict_to_struct(extra),
)
name=self.name,
camera_name=camera_name,
return_image=return_image,
return_classifications=return_classifications,
return_detections=return_detections,
return_object_point_clouds=return_object_point_clouds,
extra=dict_to_struct(extra),
)
response: CaptureAllFromCameraResponse = await self.client.CaptureAllFromCamera(request, timeout=timeout)
result = CaptureAllResult()
result.extra = struct_to_dict(response.extra)
Expand Down Expand Up @@ -188,7 +188,7 @@ async def get_properties(
name=self.name,
extra=dict_to_struct(extra),
)
response : GetPropertiesResponse = await self.client.GetProperties(request, timeout=timeout)
response: GetPropertiesResponse = await self.client.GetProperties(request, timeout=timeout)
return response

async def do_command(
Expand Down
10 changes: 6 additions & 4 deletions src/viam/services/vision/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class CaptureAllResult:
"there was no request for the classifier/detector to return a result" vs.
"the classifier/detector was requested, but there were no results".
"""

def __init__(self, image=None, classifications=None, detections=None, objects=None, extra={}):
"""
Args:
Expand Down Expand Up @@ -51,6 +52,7 @@ class Vision(ServiceBase):
vision implementations. This cannot be used on its own. If the ``__init__()`` function is
overridden, it must call the ``super().__init__()`` function.
"""

SUBTYPE: Final = Subtype( # pyright: ignore [reportIncompatibleVariableOverride]
RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_SERVICE, "vision"
)
Expand Down Expand Up @@ -283,10 +285,10 @@ async def get_object_point_clouds(

@abc.abstractmethod
async def get_properties(
self,
*,
extra: Optional[Mapping[str, Any]] = None,
timeout: Optional[float] = None,
self,
*,
extra: Optional[Mapping[str, Any]] = None,
timeout: Optional[float] = None,
) -> Properties:
"""
Get info about what vision methods the vision service provides. Currently returns boolean values that
Expand Down
7 changes: 5 additions & 2 deletions tests/mocks/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
from viam.services.mlmodel.utils import flat_tensors_to_ndarrays, ndarrays_to_flat_tensors
from viam.services.navigation import Navigation
from viam.services.slam import SLAM
from viam.services.vision import Vision, CaptureAllResult
from viam.services.vision import CaptureAllResult, Vision
from viam.utils import ValueTypes, datetime_to_timestamp, dict_to_struct, struct_to_dict


Expand Down Expand Up @@ -360,7 +360,10 @@ def __init__(
super().__init__(name)

async def get_properties(
self, *, extra: Optional[Mapping[str, Any]] = None, timeout: Optional[float] = None,
self,
*,
extra: Optional[Mapping[str, Any]] = None,
timeout: Optional[float] = None,
) -> Vision.Properties:
self.extra = extra
self.timeout = timeout
Expand Down
13 changes: 2 additions & 11 deletions tests/test_vision_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@
VisionServiceStub,
)
from viam.resource.manager import ResourceManager
from viam.services.vision import (
Classification,
Detection,
Vision,
VisionClient,
)
from viam.services.vision import Classification, Detection, Vision, VisionClient
from viam.services.vision.service import VisionRPCService
from viam.utils import dict_to_struct, struct_to_dict

Expand Down Expand Up @@ -215,11 +210,7 @@ async def test_capture_all_from_camera(self, vision: MockVision, service: Vision
client = VisionServiceStub(channel)
extra = {"foo": "capture_all_from_camera"}
request = CaptureAllFromCameraRequest(
name=vision.name,
camera_name="fake-camera",
return_image=True,
return_classifications=True,
extra=dict_to_struct(extra)
name=vision.name, camera_name="fake-camera", return_image=True, return_classifications=True, extra=dict_to_struct(extra)
)
response: CaptureAllFromCameraResponse = await client.CaptureAllFromCamera(request)
assert response.image.image == VISION_IMAGE.data
Expand Down

0 comments on commit cc1e715

Please sign in to comment.