Repository navigation
Call ensure_connected on all ophyd_async devices - #865
Conversation
7278a22 to
eded5b3
Compare
d7d1e7a to
03ad2f0
Compare
|
This is the correct solution but I think we need to think a bit more about UX in the implementation. The problem is that we are now blurring the boundaries between instantiation and connection and muddying the error messages. There are 3 paths to the display output depending on device configuration: flowchart TD
A[dodal connect] --> B(device_instantiation)
B --> C{wait_for_connection?}
C -->|True| D{Connection Error?}
C -->|False| E[ensure_connected with RE]
D -->|True| F[Display connection error from dodal]
D -->|False| G[Display connection success]
E --> H{Connection Error?}
H -->|False| G
H -->|True| I[Display connection error from RE]
Presumably we want to aim for one of these two: flowchart TD
A[dodal connect] --> B(device_instantiation)
B --> C{Instantiation error?}
C -->|False| D[Display instantiation success]
D --> E[Attempt connection]
C -->|True| F[Display instantiation error]
E --> H{Connection error?}
H -->|True| I[Display connection error]
H -->|False| J[Display connection success]
flowchart TD
A[dodal connect] --> B(device_instantiation)
B --> C{Instantiation error?}
C -->|False| E[Attempt connection]
C -->|True| J
E --> H{Connection error?}
H -->|True| I[Display connection error]
H -->|False| J[Display connection success]
Could do with opinions on which solution we want, also @coretl any opinions on changes needed for ophyd-async? In either case I think I'd want an easier way to introspection connection errors. |
|
Here's the code for Basically |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #865 +/- ##
==========================================
+ Coverage 95.78% 95.80% +0.02%
==========================================
Files 133 133
Lines 5476 5506 +30
==========================================
+ Hits 5245 5275 +30
Misses 231 231 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Alternatively I can make |
|
@coretl I think either way I'll make cleaning up the error messages a separate ticket.
That sounds very useful in general, raised an issue: bluesky/ophyd-async#647 |
|
The tests should be fixed by: bluesky/ophyd-async#646 |
7384006 to
a28a0b9
Compare
6c57567 to
4cd1375
Compare
There was a problem hiding this comment.
I think comparing with the old version we're missing some errors, the output is also not as pretty. Old:
(.venv) [ffv81422@ws455 dodal]$ dodal connect i03
Attempting connection to i03 (using dodal.beamlines.i03)
25 devices connected:
aperture_scatterguard
attenuator
backlight
cryo_stream
detector_motion
eiger
flux
lower_gonio
mirror_voltages
oav
panda_fast_grid_scan
qbpm
robot
s4_slit_gaps
sample_shutter
smargon
synchrotron
thawer
undulator
vfm
webcam
xbpm_feedback
xspress3mini
zebra
zebra_fast_grid_scan
Traceback (most recent call last):
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/bin/dodal", line 8, in <module>
sys.exit(main())
^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/dodal/src/dodal/cli.py", line 71, in connect
raise NotConnected(exceptions)
ophyd_async.core._utils.NotConnected:
zocalo: TypeError: Expected Array1D[dtype], got numpy.ndarray[typing.Any, numpy.dtype[numpy.uint64]]
panda: NotConnected:
coros: NotConnected: pva://BL03I-EA-PANDA-01:PVI
undulator_dcm: TypeError: Expected Array1D[dtype], got numpy.ndarray[typing.Any, numpy.dtype[numpy.uint64]]
pin_tip_detection: TypeError: Expected Array1D[dtype], got numpy.ndarray[typing.Any, numpy.dtype[numpy.uint32]]
dcm: TypeError: Expected Array1D[dtype], got numpy.ndarray[typing.Any, numpy.dtype[numpy.uint64]]
vs. new:
(.venv) [ffv81422@ws455 mx-bluesky]$ dodal connect i03
Attempting connection to i03 (using dodal.beamlines.i03)
ERROR:bluesky:Run aborted
Traceback (most recent call last):
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/bluesky/run_engine.py", line 1605, in _run
msg = self._plan_stack[-1].send(resp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/ophyd_async/plan_stubs/_ensure_connected.py", line 29, in ensure_connected
raise connect_task.exception()
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/ophyd_async/core/_utils.py", line 145, in wait_for_connection
raise NotConnected.with_other_exceptions_logged(exceptions)
ophyd_async.core._utils.NotConnected:
panda: NotConnected: pva://BL03I-EA-PANDA-01:PVI
Traceback (most recent call last):
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/bin/dodal", line 8, in <module>
sys.exit(main())
^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/dodal/src/dodal/cli.py", line 67, in connect
_connect_devices(RE, devices, sim_backend)
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/dodal/src/dodal/cli.py", line 94, in _connect_devices
RE(ensure_connected(*ophyd_async_devices.values(), mock=sim_backend))
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/bluesky/run_engine.py", line 973, in __call__
plan_return = self._resume_task(init_func=_build_task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/bluesky/run_engine.py", line 1109, in _resume_task
raise exc
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/bluesky/run_engine.py", line 1751, in _run
raise err
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/bluesky/run_engine.py", line 1605, in _run
msg = self._plan_stack[-1].send(resp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/ophyd_async/plan_stubs/_ensure_connected.py", line 29, in ensure_connected
raise connect_task.exception()
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/ophyd_async/core/_utils.py", line 145, in wait_for_connection
raise NotConnected.with_other_exceptions_logged(exceptions)
ophyd_async.core._utils.NotConnected:
panda: NotConnected: pva://BL03I-EA-PANDA-01:PVI
Specific issues:
- Old style gave me a list of all the devices that were happy, this was good as a sanity check
- New style is not telling me about
zocalo,dcmorpin_tip_detectionerrors
Could be because we're not swallowing the errors and then checking subsequent devices?
Also, May be scope creep but I wonder if it's worth just swallowing the stack trace for the connect? It's not helpful to a user
7df7d0d to
f826f65
Compare
| "click", | ||
| "ophyd", | ||
| "ophyd-async==0.8.0a4", | ||
| "ophyd-async==0.8.0a5", |
There was a problem hiding this comment.
Does this need a5, for exception being returned by the RunEngine?
There was a problem hiding this comment.
It needs it for NotConnected.sub_errors, will rebase this now #899 is merged
| if isinstance(device, OphydV1Device): | ||
| ophyd_devices[name] = device | ||
| elif isinstance(device, OphydV2Device): | ||
| ophyd_async_devices[name] = device |
There was a problem hiding this comment.
I think these should be switched- OphydV2Device means it must extend from Device, OphydV1Device just means it complies to one of a set of Protocols- which V2 devices also use.
There was a problem hiding this comment.
Try adding a test with an OphydV2Device that has a read method.
There was a problem hiding this comment.
...maybe not? OphydV1Device is just an alias for ophyd.device.Device and OphydV2Device is just an alias for ophyd_async.core.Device.
f826f65 to
185e018
Compare
DominicOram
left a comment
There was a problem hiding this comment.
Looks good, thanks. Minor nit is that I now get the connection errors twice:
Attempting connection to i03 (using dodal.beamlines.i03)
ERROR:bluesky:Run aborted
Traceback (most recent call last):
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/bluesky/run_engine.py", line 1605, in _run
msg = self._plan_stack[-1].send(resp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/ophyd_async/plan_stubs/_ensure_connected.py", line 33, in ensure_connected
raise connect_task.exception()
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/ophyd_async/core/_utils.py", line 152, in wait_for_connection
raise NotConnected.with_other_exceptions_logged(exceptions)
ophyd_async.core._utils.NotConnected:
panda: NotConnected: pva://BL03I-EA-PANDA-01:PVI
undulator_dcm: NotConnected:
dcm: NotConnected:
crystal_metadata_d_spacing: NotConnected: ca://DSPACING:RBV
pin_tip_detection: NotConnected:
array_data: NotConnected: pva://BL03I-DI-OAV-01:PVA:ARRAY
dcm: NotConnected:
crystal_metadata_d_spacing: NotConnected: ca://DSPACING:RBV
26 devices connected:
aperture_scatterguard
attenuator
backlight
cryo_stream
detector_motion
eiger
flux
lower_gonio
mirror_voltages
oav
panda_fast_grid_scan
qbpm
robot
s4_slit_gaps
sample_shutter
smargon
synchrotron
thawer
undulator
vfm
webcam
xbpm_feedback
xspress3mini
zebra
zebra_fast_grid_scan
zocalo
Traceback (most recent call last):
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/bin/dodal", line 8, in <module>
sys.exit(main())
^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/dodal/src/dodal/cli.py", line 76, in connect
raise NotConnected(exceptions)
ophyd_async.core._utils.NotConnected:
panda: NotConnected: pva://BL03I-EA-PANDA-01:PVI
undulator_dcm: NotConnected:
dcm: NotConnected:
crystal_metadata_d_spacing: NotConnected: ca://DSPACING:RBV
pin_tip_detection: NotConnected:
array_data: NotConnected: pva://BL03I-DI-OAV-01:PVA:ARRAY
dcm: NotConnected:
crystal_metadata_d_spacing: NotConnected: ca://DSPACING:RBV
Once before the list of connected devices and once after. This isn't a massive deal though so not holding up merge based on it.
Fixes #864
Instructions to reviewer on how to test:
Checks for reviewer
dodal connect ${BEAMLINE}