Skip to content

Commit 04cbeb5

Browse files
committed
Use find_device from device endpoint
Using the find_device method instead of looking devices up in the map of devices directly means child devices can be found, eg 'stage.x' could be a valid device but isn't in the devices map in its own right.
1 parent 2ba131e commit 04cbeb5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/blueapi/service/interface.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ def get_devices() -> list[DeviceModel]:
141141

142142
def get_device(name: str) -> DeviceModel:
143143
"""Retrieve device by name from the BlueskyContext"""
144-
return DeviceModel.from_device(context().devices[name])
144+
if not (device := context().find_device(name)):
145+
raise KeyError(name)
146+
147+
return DeviceModel.from_device(device)
145148

146149

147150
def submit_task(task_request: TaskRequest) -> str:

0 commit comments

Comments
 (0)