Skip to content

Refactor wrapped scan plans so they more user friendly#2050

Open
oliwenmandiamond wants to merge 13 commits into
mainfrom
refactor_scans_so_they_are_flatter
Open

Refactor wrapped scan plans so they more user friendly#2050
oliwenmandiamond wants to merge 13 commits into
mainfrom
refactor_scans_so_they_are_flatter

Conversation

@oliwenmandiamond

@oliwenmandiamond oliwenmandiamond commented May 7, 2026

Copy link
Copy Markdown
Contributor

This change aims to make the scan syntax much more user friendly. Some examples are show below:

Old syntax

from dodal.plans import wrapped as dpw
>>> RE(dpw.list_grid_scan([], [(x, [1, 5, 10, 50]), (y, [2, 5, 10, 15, 18])]))
>>> RE(dpw.step_grid_scan([], [(x, [1, 10, 1]), (y, [1, 5, 1])]))
# Blueapi client example
>>> bc.plans.step_grid_scan([], [(x, [1, 10, 1]), (y, [1, 5, 1])])

New syntax

>>> RE(dpw.list_grid_scan([], [x, [1, 5, 10, 50], y, [2, 5, 10, 15, 18]]))
>>> RE(dpw.step_grid_scan([], [x, 1, 10, 1, y, 1, 5, 1]))
# Blueapi client example
>>> bc.plans.step_grid_scan([], [x, 1, 10, 1, y, 1, 5, 1])

When BlueAPI supports *args, we can simplifier this even further by removing the final set of brackets:

>>> RE(dpw.step_grid_scan([], x, 1, 10, 1, y, 1, 5, 1))

or BlueAPI client equivalent

>>> bc.plans.step_grid_scan([], x, 1, 10, 1, y, 1, 5, 1)

I've also tried to improve the tests, they now check that the scan shape is correct and checks every custom error message for scan syntax being wrong for step scans.

Instructions to reviewer on how to test:

  1. Check implementation and logic is correct
  2. Test coverage is sufficient.

Checks for reviewer

  • Would the PR title make sense to a scientist on a set of release notes
  • If a new device has been added does it follow the standards
  • If changing the API for a pre-existing device, ensure that any beamlines using this device have updated their Bluesky plans accordingly
  • Have the connection tests for the relevant beamline(s) been run via dodal connect ${BEAMLINE}

@oliwenmandiamond oliwenmandiamond changed the title Refactor scans so they are flatter Refactor wrapped scan plans so they are flatter May 7, 2026
@codecov

codecov Bot commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.12%. Comparing base (767b87c) to head (40947ec).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2050      +/-   ##
==========================================
- Coverage   99.12%   99.12%   -0.01%     
==========================================
  Files         336      336              
  Lines       13065    13053      -12     
==========================================
- Hits        12951    12939      -12     
  Misses        114      114              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oliwenmandiamond oliwenmandiamond marked this pull request as ready for review May 11, 2026 07:24
@oliwenmandiamond oliwenmandiamond requested a review from a team as a code owner May 11, 2026 07:24
@oliwenmandiamond oliwenmandiamond changed the title Refactor wrapped scan plans so they are flatter Refactor wrapped scan plans so they more user friendly May 11, 2026

@EmsArnold EmsArnold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments, but hopefully nothing too onerous. I would like to try it on test rig or similar if it hasn't been tested there yet.

Comment on lines 109 to 111
description="List of tuples (device, parameter). For independent \
trajectories, provide '[(movable1, [start1, stop1, num1]), (movable2, \
[start2, stop2, num2]), ... , (movableN, [startN, stopN, numN])]'."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: have an updated description

description="Sequence of Movable, float, or int. For independent \
trajectories, provide '[movable 1, start1, stop1, num1, movable2, \
start2, stop2, num2, ..., movableN, startN, stopN, numN]'."

list[tuple[Movable, list[float | int]]],
Sequence[Movable | float | int],
Field(
description="List of tuples (device, parameter). For concurrent \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: have an updated description

description="Sequence of Movable, float, or int. ...

Comment on lines 169 to 171
description="List of tuples (device, parameter). For independent \
trajectories, provide '[(movable1, [start1, stop1, num1]), (movable2, \
[start2, stop2, num2]), ... , (movableN, [startN, stopN, numN])]'."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: have an updated description

description="Sequence of Movable, float, or int. For independent \
trajectories, provide '[movable 1, start1, stop1, num1, movable2, \
start2, stop2, num2, ..., movableN, startN, stopN, numN]'."

],
params: Annotated[
list[tuple[Movable, list[float | int]]],
list[Movable | list[float | int]],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for this remain a list rather than a Sequence, as the others have been swapped?

Comment on lines 215 to 218
description="List of tuples (device, positions). For concurrent \
trajectories, provide '[(movable1, [point1, point2, ...]), (movable2, \
[point1, point2, ...]), ... , (movableN, [point1, point2, ...])]'. Number \
of points for each movable must be equal."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: have an updated description

description="Sequence of Movable or list containing float or int. For concurrent \
trajectories, provide '[movable 1, [point1, point2, ...], movable2, [point1, point2, ...], \
..., movableN, [point1, point2, ...]]'. Number of points for each movable must be equal."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants