Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0adc946
Refactor scans so they are flatter
oliwenmandiamond May 1, 2026
9ad324a
Update step scan logic, tests pass
oliwenmandiamond May 7, 2026
8a476aa
Add error message to _make_stepped_list_num
oliwenmandiamond May 7, 2026
7a948f8
Update doc strings and _make_step_scan_args_and_shape logic
oliwenmandiamond May 8, 2026
4473ec5
Add stronger tests for invalid arguments
oliwenmandiamond May 8, 2026
d93ba1a
Added additional test to check for scan shape
oliwenmandiamond May 8, 2026
6503982
Fix shape test
oliwenmandiamond May 8, 2026
ed2c7e2
Add test for require
oliwenmandiamond May 8, 2026
6ee9bfd
Fix and optimise tests
oliwenmandiamond May 8, 2026
4a61b72
Merge branch 'main' into refactor_scans_so_they_are_flatter
oliwenmandiamond May 8, 2026
2c4587a
Update comments
oliwenmandiamond May 8, 2026
647d095
Update doc strings and error msgs
oliwenmandiamond May 11, 2026
40947ec
Merge branch 'main' into refactor_scans_so_they_are_flatter
oliwenmandiamond May 20, 2026
72fe2ae
Merge branch 'main' into refactor_scans_so_they_are_flatter
oliwenmandiamond Sep 2, 2026
425e708
Merge branch 'refactor_scans_so_they_are_flatter' of ssh://github.com…
oliwenmandiamond Sep 2, 2026
b30a406
Changes so far
oliwenmandiamond Sep 4, 2026
f5f6b75
Simply _round_list_elements and add doc strings to all uitls functions
oliwenmandiamond Sep 4, 2026
d6b910a
Update validators to use templates
oliwenmandiamond Sep 4, 2026
3f6b07f
Add back utils tests
oliwenmandiamond Sep 4, 2026
8e5c010
Separate out types and annotations
oliwenmandiamond Sep 4, 2026
32aa33c
Tidy up
oliwenmandiamond Sep 4, 2026
c482a9d
Update to be paramertised tests for complicance test, also remove no …
oliwenmandiamond Sep 4, 2026
5ed89cf
Correct remaining tests plus add doc string
oliwenmandiamond Sep 4, 2026
99728ba
Add missing code coverage
oliwenmandiamond Sep 4, 2026
4bd9b64
Remove commented out code
oliwenmandiamond Sep 4, 2026
9763df2
Reduce test_wrapped lines
oliwenmandiamond Sep 4, 2026
4ea39fe
Update doc strings for scan plans
oliwenmandiamond Sep 4, 2026
b959329
Merge branch 'main' into refactor_scans_so_they_are_flatter
oliwenmandiamond Sep 4, 2026
0d65b0b
Add missing plan typing for spec_path
oliwenmandiamond Sep 4, 2026
f32aa86
Assume blueapi supports *args
oliwenmandiamond Sep 4, 2026
057b47d
Use CustomPlanMetadata
oliwenmandiamond Sep 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions src/dodal/plans/__init__.py
Original file line number Diff line number Diff line change
@@ -1,33 +0,0 @@
from .spec_path import spec_scan
from .wrapped import (
count,
list_grid_rscan,
list_grid_scan,
list_rscan,
list_scan,
num_grid_rscan,
num_grid_scan,
num_rscan,
num_scan,
step_grid_rscan,
step_grid_scan,
step_rscan,
step_scan,
)

__all__ = [
"count",
"list_grid_rscan",
"list_grid_scan",
"list_rscan",
"list_scan",
"num_grid_rscan",
"num_grid_scan",
"num_rscan",
"num_scan",
"spec_scan",
"step_grid_rscan",
"step_grid_scan",
"step_rscan",
"step_scan",
]
33 changes: 33 additions & 0 deletions src/dodal/plans/scans/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from .spec_path import spec_scan
from .wrapped import (
count,
list_grid_rscan,
list_grid_scan,
list_rscan,
list_scan,
num_grid_rscan,
num_grid_scan,
num_rscan,
num_scan,
step_grid_rscan,
step_grid_scan,
step_rscan,
step_scan,
)

__all__ = [
"count",
"list_grid_rscan",
"list_grid_scan",
"list_rscan",
"list_scan",
"num_grid_rscan",
"num_grid_scan",
"num_rscan",
"num_scan",
"spec_scan",
"step_grid_rscan",
"step_grid_scan",
"step_rscan",
"step_scan",
]
92 changes: 92 additions & 0 deletions src/dodal/plans/scans/annotations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
from typing import Annotated as A

from pydantic import BeforeValidator, Field

from dodal.plans.scans.types import (
Detectors,
MovableListOfPoints,
MovableStartStep,
MovableStartStop,
MovableStartStopNum,
MovableStartStopStep,
)
from dodal.plans.scans.validators import trajectory_validator

DetectorsA = A[
Detectors,
Field(
description="Set of readable devices, will take a reading at each point",
),
]

MovableStartStepA = A[
MovableStartStep,
Field(
description="Trajectory defined by a movable, start position, and step size."
),
BeforeValidator(
trajectory_validator(
length=3,
template="(movable, start, step)",
expected_type=MovableStartStep,
)
),
]

MovableStartStopA = A[
MovableStartStop,
Field(
description="Trajectory defined by a movable, start position, and stop position.",
),
BeforeValidator(
trajectory_validator(
length=3,
template="(movable, start, stop)",
expected_type=MovableStartStop,
)
),
]

MovableStartStopNumA = A[
MovableStartStopNum,
Field(
description="Trajectory defined by a movable, start position, stop position, "
"and number of points."
),
BeforeValidator(
trajectory_validator(
length=4,
template="(movable, start, stop, num)",
expected_type=MovableStartStopNum,
)
),
]

MovableListOfPointsA = A[
MovableListOfPoints,
Field(
description="Trajectory defined by a movable and a list of positions to move to."
),
BeforeValidator(
trajectory_validator(
length=2,
template="(movable, [point1, point2, ...])",
expected_type=MovableListOfPoints,
)
),
]

MovableStartStopStepA = A[
MovableStartStopStep,
Field(
description="Trajectory defined by a movable, start position, stop position, "
"and step size."
),
BeforeValidator(
trajectory_validator(
length=4,
template="(movable, start, stop, step)",
expected_type=MovableStartStopStep,
)
),
]
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
import operator
from functools import reduce
from typing import Annotated, Any
from typing import Annotated

import bluesky.plans as bp
from bluesky.protocols import Movable, Readable
from bluesky.protocols import Movable
from bluesky.utils import CustomPlanMetadata, plan
from cycler import Cycler, cycler
from pydantic import Field, validate_call
from scanspec.specs import Spec

from dodal.common import MsgGenerator
from dodal.plan_stubs.data_session import attach_data_session_metadata_decorator
from dodal.plans.scans.annotations import DetectorsA


@attach_data_session_metadata_decorator()
@validate_call(config={"arbitrary_types_allowed": True})
@plan
def spec_scan(
detectors: Annotated[
set[Readable],
Field(
description="Set of readable devices, will take a reading at each point, \
in addition to any Movables in the Spec",
),
],
detectors: DetectorsA,
spec: Annotated[
Spec[Movable],
Field(description="ScanSpec modelling the path of the scan"),
],
metadata: dict[str, Any] | None = None,
metadata: CustomPlanMetadata | None = None,
) -> MsgGenerator:
"""Generic plan for reading `detectors` at every point of a ScanSpec `Spec`.
A `Spec` is an N-dimensional path.
Expand All @@ -44,7 +41,7 @@ def spec_scan(
**(metadata or {}),
}

yield from bp.scan_nd(tuple(detectors), _as_cycler(spec), md=_md)
yield from bp.scan_nd(detectors, _as_cycler(spec), md=_md)


def _as_cycler(spec: Spec[Movable]) -> Cycler:
Expand Down
19 changes: 19 additions & 0 deletions src/dodal/plans/scans/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from collections.abc import Sequence
from typing import Any

from bluesky.protocols import Movable, Readable
from ophyd_async.core import AsyncReadable

Number = float | int

Detectors = Sequence[Readable | AsyncReadable]

MovableStartStep = tuple[Movable[Number], Number, Number]

MovableStartStop = tuple[Movable[Number], Number, Number]

MovableStartStopNum = tuple[Movable[Number], Number, Number, int]

MovableListOfPoints = tuple[Movable[Any], list[Any]]

MovableStartStopStep = tuple[Movable[Number], Number, Number, Number]
Loading
Loading