DiamondLightSource / DiamondLightSource/dodal
DeviceManager cannot give child devices
- Dominant language
- Python
- Stars
- 5
- Forks
- 13
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 10
Description
When using dodal connect, it only shows devices that are tagged with `@devices.factory()`. When a device fails, it will then show any sub devices not connected e.g
```
$ dodal connect i19-2
Attempting connection to i19-2 (using dodal.beamlines.i19_2)
12 devices connected:
attenuator_motor_squad
beamstop
dcm_ro
diffractometer
energy_device
hfm_piezo
pinhole_and_collimator
serial_stages
shutter
synchrotron
vfm_piezo
zebra
Traceback (most recent call last):
File "/cache/venv-for/scratch/bluesky_development/sm-bluesky/bin/dodal", line 10, in
sys.exit(main())
^^^^^^
File "/cache/venv-for/scratch/bluesky_development/sm-bluesky/lib/python3.11/site-packages/click/core.py", line 1631, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/cache/venv-for/scratch/bluesky_development/sm-bluesky/lib/python3.11/site-packages/click/core.py", line 1552, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/cache/venv-for/scratch/bluesky_development/sm-bluesky/lib/python3.11/site-packages/click/core.py", line 2032, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/cache/venv-for/scratch/bluesky_development/sm-bluesky/lib/python3.11/site-packages/click/core.py", line 1415, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/cache/venv-for/scratch/bluesky_development/sm-bluesky/lib/python3.11/site-packages/click/core.py", line 910, in invoke
return callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/cache/venv-for/scratch/bluesky_development/sm-bluesky/lib/python3.11/site-packages/dodal/cli.py", line 132, in connect
raise NotConnectedError(exceptions)
ophyd_async.core._utils.NotConnectedError:
panda: NotConnectedError: pva://BL19I-EA-PANDA-01:PVI
backlight: NotConnectedError:
position: NotConnectedError: ca://BL19I-EA-IOC-12:AD1:choiceButton
eiger: NotConnectedError: pva://BL19I-EA-EIGER-01:PVI
```
It would be useful if DeviceManager could output all devices along with their child devices. Then when you use dodal connect, you can effectively display all of your beamline devices structure.
This would also be useful for blueapi. Currently, BlueapiClient asks DeviceManager for all devices and caches them. However, if you need to access any child devices, the client has no idea if a child device exists until the users asks for it and caches it of throw error. It should provide all devices upfront including sub devices so the cache works correctly.
ophyd-async `Device` already provides a handy way to do this as it provides a children function that maps all child devices a Device has.
Contributor guide
Research direction
Start by reading DeviceManager and its use in the dodal connect command, then inspect Device.children in ophyd-async and how BlueapiClient caches devices. Done means DeviceManager exposes parent and child devices consistently, dodal connect can display the full device structure, and BlueapiClient can discover child devices without lazy lookup failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100