Skip to content

BlueapiClient reports successful response on device move when actually fails #1446

@oliwenmandiamond

Description

@oliwenmandiamond

When trying to use BlueapiClient, I tried to move a shutter as shown below for i09:

>>> from blueapi.client import BlueapiClient
>>> bc = BlueapiClient.from_config_file("/home/xol73553/Documents/BLUESKY/i09_blueapi_client_config.yaml")
>>> for device in bc.devices:
...     print(device)
... 
<Response [200]>
dcm
lakeshore
psi2
psj2
psi1
psk1
fsj1
psj1
jphase
pgm
jgap
iid
ienergy_order
fsi1
...
>>> devices = bc.devices
>>> plans = bc.plans
<Response [200]>
>>> plans.move({devices.fsj1: "OUT"})
<Response [201]>
<Response [200]>
>>> plans.move({devices.fsj1: "IN"})
<Response [201]>
<Response [200]>

(I modified the code to print the response it received). As you can see, it is reporting the status as success, however the shutters were never moved... Looking at the logs in BlueAPI, I can see the following:

The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/app/.venv/lib/python3.11/site-packages/blueapi/worker/task_worker.py", line 441, in process_task
    result = self._current.task.do_task(self._ctx)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/blueapi/worker/task.py", line 41, in do_task
    result = ctx.run_engine(func(**prepared_params))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/bluesky/run_engine.py", line 976, in __call__
    plan_return = self._resume_task(init_func=_build_task)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/bluesky/run_engine.py", line 1121, in _resume_task
    raise exc
  File "/app/.venv/lib/python3.11/site-packages/bluesky/run_engine.py", line 1756, in _run
    raise err
  File "/app/.venv/lib/python3.11/site-packages/bluesky/run_engine.py", line 1585, in _run
    msg = self._plan_stack[-1].throw(stashed_exception or resp)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/dodal/src/dodal/plan_stubs/wrapped.py", line 75, in move
    yield from bps.mv(*itertools.chain.from_iterable(moves.items()), group=group)
  File "/app/.venv/lib/python3.11/site-packages/bluesky/utils/__init__.py", line 1975, in __iter__
    return (yield from self._iter)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/bluesky/plan_stubs.py", line 395, in mv
    yield Msg("wait", None, group=group, timeout=timeout)
  File "/app/.venv/lib/python3.11/site-packages/bluesky/run_engine.py", line 2378, in _status_object_completed
    raise FailedStatus(ret) from exc
bluesky.utils.FailedStatus: <AsyncStatus, device: fsj1, task: <coroutine object AsyncStatusBase.__init__.<locals>.wait_with_error_message at 0x7fc9baf97840>, errored: ValueError("OUT is not a valid choice for BL09J-EA-FSHTR-01:CTRL, valid choices: ['Out', 'In']")>
2026-03-20 11:53:20,751     INFO blueapi.worker.task_worker Awaiting task 

The shutter never moved because the plan failed because it didn't use a valid enum. This needs to be changed in BlueAPI so that this error is propagated to the user and doesn't falsely return a valid response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions