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-9560: remove AnalogNames and DigitalInterruptNames from python sdk #808

Merged
merged 2 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 0 additions & 6 deletions examples/server/v1/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,6 @@ async def gpio_pin_by_name(self, name: str) -> Board.GPIOPin:
except KeyError:
raise ResourceNotFoundError("Board.GPIOPin", name)

async def analog_names(self) -> List[str]:
return [key for key in self.analogs.keys()]

async def digital_interrupt_names(self) -> List[str]:
return [key for key in self.digital_interrupts.keys()]

async def set_power_mode(self, **kwargs):
raise NotImplementedError()

Expand Down
38 changes: 0 additions & 38 deletions src/viam/components/board/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,44 +364,6 @@ async def gpio_pin_by_name(self, name: str) -> GPIOPin:
"""
...

@abc.abstractmethod
async def analog_names(self) -> List[str]:
"""
Get the names of all known analog readers and/or writers.

::

my_board = Board.from_robot(robot=machine, name="my_board")

# Get the name of every Analog configured on the board.
names = await my_board.analog_names()

Returns:
List[str]: The list of names of all known analog readers/writers.

For more information, see `Board component <https://docs.viam.com/components/board/>`_.
"""
...

@abc.abstractmethod
async def digital_interrupt_names(self) -> List[str]:
"""
Get the names of all known digital interrupts.

::

my_board = Board.from_robot(robot=machine, name="my_board")

# Get the name of every DigitalInterrupt configured on the board.
names = await my_board.digital_interrupt_names()

Returns:
List[str]: The names of the digital interrupts.

For more information, see `Board component <https://docs.viam.com/components/board/>`_.
"""
...

@abc.abstractmethod
async def set_power_mode(
self, mode: PowerMode.ValueType, duration: Optional[timedelta] = None, *, timeout: Optional[float] = None, **kwargs
Expand Down
10 changes: 0 additions & 10 deletions src/viam/components/board/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,6 @@ async def digital_interrupt_by_name(self, name: str) -> Board.DigitalInterrupt:
async def gpio_pin_by_name(self, name: str) -> Board.GPIOPin:
return GPIOPinClient(name, self)

async def analog_names(self) -> List[str]:
if self._analog_names is None:
return []
return self._analog_names

async def digital_interrupt_names(self) -> List[str]:
if self._digital_interrupt_names is None:
return []
return self._digital_interrupt_names

async def do_command(
self,
command: Mapping[str, ValueTypes],
Expand Down
6 changes: 0 additions & 6 deletions tests/mocks/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,6 @@ async def gpio_pin_by_name(self, name: str) -> Board.GPIOPin:
except KeyError:
raise ResourceNotFoundError("Board.GPIOPin", name)

async def analog_names(self) -> List[str]:
return [key for key in self.analogs.keys()]

async def digital_interrupt_names(self) -> List[str]:
return [key for key in self.digital_interrupts.keys()]

async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) -> List[Geometry]:
self.extra = extra
self.timeout = timeout
Expand Down
28 changes: 0 additions & 28 deletions tests/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,6 @@ async def test_gpio_pin_by_name(self, board: MockBoard):
pin = await board.gpio_pin_by_name("pin1")
assert pin.name == "pin1"

async def test_analog_names(self, board: MockBoard):
names = await board.analog_names()
assert names == ["analog1"]

async def test_digital_interrupt_names(self, board: MockBoard):
names = await board.digital_interrupt_names()
assert names == ["interrupt1"]

async def test_do(self, board: MockBoard):
command = {"command": "args"}
resp = await board.do_command(command)
Expand Down Expand Up @@ -357,26 +349,6 @@ async def test_gpio_pin_by_name(self, board: MockBoard, service: BoardRPCService
pin = await client.gpio_pin_by_name("pin1")
assert pin.name == "pin1"

async def test_analog_names(self, board: MockBoard, service: BoardRPCService):
async with ChannelFor([service]) as channel:
client = BoardClient(name=board.name, channel=channel)

reader = await client.analog_by_name("analog1")
assert reader.name == "analog1"

names = await client.analog_names()
assert names == ["analog1"]

async def test_digital_interrupt_names(self, board: MockBoard, service: BoardRPCService):
async with ChannelFor([service]) as channel:
client = BoardClient(name=board.name, channel=channel)

interrupt = await client.digital_interrupt_by_name("interrupt1")
assert interrupt.name == "interrupt1"

names = await client.digital_interrupt_names()
assert names == ["interrupt1"]

async def test_do(self, board: MockBoard, service: BoardRPCService):
async with ChannelFor([service]) as channel:
client = BoardClient(board.name, channel)
Expand Down
Loading