DiamondLightSource / DiamondLightSource/blueapi

Plans do not function with `*args`

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

Description

Currently plans with `*args` do not function as expected.

A plan which broadly looks like:
```python
def test_move(*args: Movable[T] | T, group: Group | None = None) -> MsgGenerator:
return (yield from bps.mv(*args, group=group))
```
and is run from the client:
```python
plans = bc.plans
plans.test_move(devices.sample_stage.x, "0")
```
you receive the following error:
```python
2026-03-23 14:07:13,012 INFO blueapi.worker.task_worker Submitting: task_id='b3744ab9-b5a6-4846-ad06-060ba635a87c' task=Task(name='test_move', params={'args': 'sample_stage.x', 'group': '0'}, metadata={'user': 'vgz78127', 'instrument_session': 'cm44191-1', 'tiled_access_tags': ['{"proposal": 44191, "visit": 1, "beamline": "b01-1"}']}) request_id=None is_complete=False is_pending=True errors=[] outcome=None
2026-03-23 14:07:13,013 INFO blueapi.worker.task_worker Got new task: task_id='b3744ab9-b5a6-4846-ad06-060ba635a87c' task=Task(name='test_move', params={'args': 'sample_stage.x', 'group': '0'}, metadata={'user': 'vgz78127', 'instrument_session': 'cm44191-1', 'tiled_access_tags': ['{"proposal": 44191, "visit": 1, "beamline": "b01-1"}']}) request_id=None is_complete=False is_pending=True errors=[] outcome=None
2026-03-23 14:07:13,013 INFO blueapi.worker.task Asked to run plan test_move with {'args': 'sample_stage.x', 'group': '0'} and metadata {'user': 'vgz78127', 'instrument_session': 'cm44191-1', 'tiled_access_tags': ['{"proposal": 44191, "visit": 1, "beamline": "b01-1"}']} for all runs
2026-03-23 14:07:13,014 ERROR blueapi.worker.task_worker Task failed
2026-03-23 14:07:13,014 ERROR blueapi.worker.task_worker test_move() got an unexpected keyword argument 'args'
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))
^^^^^^^^^^^^^^^^^^^^^^^
TypeError: test_move() got an unexpected keyword argument 'args'
```
If run from the client in a slightly different manner, e.g. `plans.test_move(devices.sample_stage.x, 0)` or `plans.test_move(devices.sample_stage.x, 0, group = "foo")`, you receive a `blueapi.client.rest.InvalidParametersError` with slightly differing flavours.

This causes some of the plans (such as [`move`](https://github.com/DiamondLightSource/dodal/blob/a039d7353519568884766da3df47219d977d9401/src/dodal/plan_stubs/wrapped.py#L60) to have syntax which is significantly different from that of the underlying bluesky plan.

These wrapped `plans` and `plan_stubs` were originally written by @DiamondJoseph in [#793](https://github.com/DiamondLightSource/dodal/pull/793), and the only mention of `*args` is that [they shall not be used for plans and plan_stubs](https://github.com/DiamondLightSource/dodal/pull/793/changes#diff-28f183cf4f5f7b794b878bcfb4c48e1318c3aed9260d2d127649e2d9699ffde0R26).

## Acceptance Criteria
- Be able to use `*args` in plans, or have a reasoning/explanation for not using `*args` which is documented, perhaps in [Write Bluesky Plans for Blueapi](https://diamondlightsource.github.io/blueapi/main/how-to/write-plans.html).

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.