Skip to content

Commit

Permalink
Change test structure and add docstring to fly_and_collect
Browse files Browse the repository at this point in the history
  • Loading branch information
Rose Yemelyanova committed Oct 23, 2023
1 parent 02eb1d5 commit 03a65ec
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
31 changes: 31 additions & 0 deletions src/dls_bluesky_core/stubs/flyables.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,37 @@ def fly_and_collect(
checkpoint_every_collect: bool = False,
stream_name: str = "primary",
) -> MsgGenerator:
"""Repeatedly fly and collect a flyer, flushing with a period.
flyer.kickoff and complete are called, which starts the fly scanning process.
bps.wait is called, which finishes after each flush period and then repeats, until
complete finishes. At this point, bps.collect is called to gather the documents
produced.
For some flyers, this plan will need to be called in succession in order to, for
example, set up a flyer to send triggers and collect data without pause. For such
a use case, this plan can be setup to checkpoint for each collect.
Note: this plan must be wrapped with calls to open and close a run, and the flyer
must implement the Collectable protocol.
Args:
flyer (Flyable, Collectable): ophyd-async device which implements Flyable and
Collectable.
flush_period (float): How often to check if flyer.complete has finished.
Defaults to 0.5
checkpoint_every_collect (bool): whether or not to checkpoint after
flyer.collect has been called. Defaults to
False.
stream_name (str): name of the stream to collect from. Defaults to "primary".
Returns:
MsgGenerator: Plan
Yields:
Iterator[MsgGenerator]: Bluesky messages
"""
yield from bps.kickoff(flyer)
complete_group = group_uuid("complete")
yield from bps.complete(flyer, group=complete_group)
Expand Down
12 changes: 12 additions & 0 deletions tests/core/test_coordination.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import uuid

import pytest

from dls_bluesky_core.core.coordination import group_uuid


@pytest.mark.parametrize("group", ["foo", "bar", "baz", str(uuid.uuid4())])
def test_group_uid(group: str):
gid = group_uuid(group)
assert gid.startswith(f"{group}-")
assert not gid.endswith(f"{group}-")
10 changes: 1 addition & 9 deletions tests/core/test_funcs.py → tests/core/test_maths.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import uuid
from typing import Optional

import pytest

from dls_bluesky_core.core import group_uuid, in_micros, step_to_num
from dls_bluesky_core.core import in_micros, step_to_num


@pytest.mark.parametrize(
Expand Down Expand Up @@ -64,10 +63,3 @@ def test_step_to_num(
assert actual_start == start
assert actual_stop == truncated_stop
assert num == expected_num


@pytest.mark.parametrize("group", ["foo", "bar", "baz", str(uuid.uuid4())])
def test_group_uid(group: str):
gid = group_uuid(group)
assert gid.startswith(f"{group}-")
assert not gid.endswith(f"{group}-")

0 comments on commit 03a65ec

Please sign in to comment.