DiamondLightSource / DiamondLightSource/blueapi

Blueapi doesn't support ophyd-async DeviceVector

Open
#1,555 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
13
Forks
13
Avg merge
2d 11h
Merged PRs (30d)
25

Description

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](
https://github.com/DiamondLightSource/dodal/compare/main...device_vector_example) 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

```python
>>> 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](https://github.com/bluesky/ophyd-async/blob/main/src/ophyd_async/core/_device.py#L285) 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:

```Python
>>> 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]

>>> dv[2]

```
There are also plans for a `DeviceMap` to be added to ophyd-async too https://github.com/bluesky/ophyd-async/issues/1252.

`DeviceVector` and `DeviceMap` should probably be supported in BlueapiClient.

## Acceptance Criteria
- Can access DeviceVector children from BlueapiClient

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.