Repository navigation
Closed
Description
Currently plans with *args do not function as expected.
A plan which broadly looks like:
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:
plans = bc.plans
plans.test_move(devices.sample_stage.x, "0")you receive the following error:
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 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, and the only mention of *args is that they shall not be used for plans and plan_stubs.
Acceptance Criteria
- Be able to use
*argsin plans, or have a reasoning/explanation for not using*argswhich is documented, perhaps in Write Bluesky Plans for Blueapi.
Metadata
Metadata
Assignees
Labels
No labels
Activity
oliwenmandiamond commentedon Mar 23, 2026
So there seems to be a deliberate choice to not support *args in plans according to those docs. I don't understand why this is the case because this means any generic scan command will now not be possible in the new system even though we already have scan plans that we could use.
oliwenmandiamond commentedon Mar 26, 2026
So from your logs, we can see it is using your second value, the move position and putting it in the groups argument. I've tested to see if providing a list or args=[...] fixes it but same result
>>> plans.test_move([devs.fsj1, "Out"])>>> plans.test_move(args=[devs.fsj1, "Out"])We need to make it so if *args is used, blueapi must enforce anything after must be keyword argument and for it to even accepts args as valid.
oliwenmandiamond commentedon Mar 26, 2026
This is a more fundamental framework issue as blueapi is only designed to work with kwargs rather than args and kwargs
blueapi/worker/task.py
the
prepared_paramsruns the plan with every argument as kwargs so*argswould never work. You would have to redesign task and TaskRequest to supportrather than just parameters
Then, we can support this by giving these arguments to the plan
In the meantime, the only alternative we can do is
which becomes
rather than