Skip to content

move plan wrapped syntax is different to the wrapped command. #1983

@oliwenmandiamond

Description

@oliwenmandiamond

When trying to use BlueapiClient and trying to move a device, I tried to do the following:

>>> 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
fsi1
...
>>> devices = bc.devices
>>> plans = bc.plans
<Response [200]>
>>> plans.move(devices.fsj1, "Out")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/scratch/bluesky_development/blueapi/src/blueapi/client/client.py", line 150, in __call__
    self._client.run_task(req)
  File "/scratch/bluesky_development/blueapi/venv/lib64/python3.12/site-packages/observability_utils/tracing/decorators.py", line 151, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/scratch/bluesky_development/blueapi/src/blueapi/client/client.py", line 468, in run_task
    task_response = self._rest.create_task(task)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch/bluesky_development/blueapi/src/blueapi/client/rest.py", line 188, in create_task
    return self._request_and_deserialize(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch/bluesky_development/blueapi/venv/lib64/python3.12/site-packages/observability_utils/tracing/decorators.py", line 151, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/scratch/bluesky_development/blueapi/src/blueapi/client/rest.py", line 271, in _request_and_deserialize
    raise exception
blueapi.client.rest.InvalidParametersError: [ParameterError(loc=['body', 'params', 'moves'], msg='Input should be a valid dictionary', type='dict_type', input='fsj1')]

I expected the command to use the Bluesky syntax that it wraps. However it fails. The correct syntax is actually used like the below:

>>> plans.move({devices.fsj1: "Out"})

rather than

>>> plans.move(devices.fsj1, "Out")

This was counter intuitive to me. The doc string says Move a device, wrapper for bp.mv., implying only moving a single device. I see now that I maybe should have used set_absolute, but this was not obvious from the plan names / doc strings. I personally don't see why we can't make the moves argument this instead

args*: Movable[T] | T

If we want to allow multiple moves at once, we could use @overload to allow for both syntax or create a new command called move_group to allow for moving multiple devices at once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions