DiamondLightSource / DiamondLightSource/dodal

move plan wrapped syntax is different to the wrapped command.

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

Description

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

```Python
>>> 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)
...

dcm
lakeshore
psi2
psj2
psi1
psk1
fsj1
fsi1
...
>>> devices = bc.devices
>>> plans = bc.plans

>>> plans.move(devices.fsj1, "Out")
Traceback (most recent call last):
File "", line 1, in
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:
```Python
>>> plans.move({devices.fsj1: "Out"})
```
rather than
```Python
>>> 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.

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.