Steps to replicate the issue:
Pin dodal inside blueapi to this branch:
"dls-dodal@git+https://github.com/DiamondLightSource/dodal.git@device_vector_example". It adds a test DeviceVector device to i09.
Then run blueapi with i09 beamline in mock mode. Configuration used was:
api:
url: http://0.0.0.0:8000
env:
metadata:
instrument: adsim
sources:
- kind: deviceManager
module: dodal.beamlines.i09
mock: True
- kind: planFunctions
module: dodal.plans
- kind: planFunctions
module: dodal.plan_stubs.wrapped
stomp:
enabled: true
url: tcp://localhost:61613/
numtracker:
url: http://localhost:8406/graphql
Start blueapi server:
uv run blueapi -c /path/to/file.yaml serve
Then in another terminal
>>> from blueapi.client import BlueapiClient
>>> bc = BlueapiClient.from_config_file("/path/to/file.yaml")
>>> bc.instrument_session = "12345"
>>> plans = bc.plans
>>> devs = bc.devices
>>> devs.test
Device(test)
>>> devs.test[1]
'e'
>>> devs.test[2]
's'
The above treats the client object as a str so an index just gets the index of the name. DeviceVector is used when many child devices are required, e.g 30 channels for a device and are accessed by the associated index. It is a pain to statically type this and is much easier to have it be configured instead. For example in normal python you can do the following:
>>> from ophyd_async.core import soft_signal_rw
>>> from ophyd_async.core import DeviceVector
>>> dv = DeviceVector({1: soft_signal_rw(int), 2: soft_signal_rw(int)})
>>> dv[1]
<ophyd_async.core._signal.SignalRW object at 0x7efe71059590>
>>> dv[2]
<ophyd_async.core._signal.SignalRW object at 0x7efe71059e10>
There are also plans for a DeviceMap to be added to ophyd-async too bluesky/ophyd-async#1252.
DeviceVector and DeviceMap should probably be supported in BlueapiClient.
Acceptance Criteria
- Can access DeviceVector children from BlueapiClient
Steps to replicate the issue:
Pin dodal inside blueapi to this branch:
"dls-dodal@git+https://github.com/DiamondLightSource/dodal.git@device_vector_example". It adds a test DeviceVector device to i09.
Then run blueapi with i09 beamline in mock mode. Configuration used was:
Start blueapi server:
uv run blueapi -c /path/to/file.yaml serveThen in another terminal
The above treats the client object as a str so an index just gets the index of the name. DeviceVector is used when many child devices are required, e.g 30 channels for a device and are accessed by the associated index. It is a pain to statically type this and is much easier to have it be configured instead. For example in normal python you can do the following:
There are also plans for a
DeviceMapto be added to ophyd-async too bluesky/ophyd-async#1252.DeviceVectorandDeviceMapshould probably be supported in BlueapiClient.Acceptance Criteria