Blueapi doesn't support ophyd-async DeviceVector

未关闭
#1,555 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
python
领域
api, backend

调研方向

从 BlueapiClient 的 devices 接口开始,使用提供的 i09 mock 配置和 dodal 中的 DeviceVector 示例重现问题。检查 devs.test 和带索引的子设备是如何表示的,然后验证能否通过 BlueapiClient 使用数值索引访问 DeviceVector 的子设备。完成的标准是:验收示例不再返回设备名称中的一个字符,并且按索引访问会返回子设备。

由索引模型根据 Issue 内容生成。

描述

bug

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 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
主要语言
Python
星标
13
派生
14
平均合并
1 天 18 小时
30 天内合并 PR
17

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DiamondLightSource/blueapi 的其他 Issue

查看 DiamondLightSource/blueapi 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。