Skip to content

Commit

Permalink
Add comments and possible fix for bluesky.Movable change
Browse files Browse the repository at this point in the history
  • Loading branch information
ZohebShaikh committed Feb 28, 2025
1 parent 40b4bb1 commit 5b98fb0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/blueapi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class EnvironmentConfig(BlueapiBaseModel):
),
Source(kind=SourceKind.PLAN_FUNCTIONS, module="blueapi.startup.example_plans"),
Source(kind=SourceKind.PLAN_FUNCTIONS, module="dodal.plans"),
# This plan is not JSON serializable specifically bluesky.Moveable
# https://github.com/DiamondLightSource/dodal/blob/a3b1b8c540cea6a4180471818c258e53577856af/src/dodal/plan_stubs/wrapped.py#L18
Source(kind=SourceKind.PLAN_FUNCTIONS, module="dodal.plan_stubs.wrapped"),
]
events: WorkerEventConfig = Field(default_factory=WorkerEventConfig)
Expand Down
6 changes: 5 additions & 1 deletion tests/unit_tests/worker/devices.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Devices to use for worker tests

from typing import TypeVar

from bluesky.protocols import Movable
from ophyd import Device, DeviceStatus
from ophyd.status import Status

T = TypeVar("T")


class AdditionalUpdateStatus(DeviceStatus):
"""
Expand Down Expand Up @@ -39,7 +43,7 @@ def _run_callbacks(self) -> None:
)


class AdditionalStatusDevice(Device, Movable):
class AdditionalStatusDevice(Device, Movable[float]):
def set(self, value: float) -> Status: # type: ignore
status = AdditionalUpdateStatus(self)
return status # type: ignore
Expand Down
9 changes: 7 additions & 2 deletions tests/unit_tests/worker/test_task_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
from unittest.mock import ANY, MagicMock, patch

import pytest
from bluesky.protocols import Movable
from dodal.common.types import UpdatingPathProvider
from observability_utils.tracing import (
JsonObjectSpanExporter,
asserting_span_exporter,
)
from ophyd_async.core import AsyncStatus

from blueapi.config import EnvironmentConfig, Source, SourceKind
from blueapi.core import BlueskyContext, EventStream, MsgGenerator
Expand All @@ -38,8 +40,10 @@
)
_FAILING_TASK = Task(name="failing_plan", params={})

T = TypeVar("T")

class FakeDevice:

class FakeDevice(Movable):
event: threading.Event

@property
Expand All @@ -49,7 +53,8 @@ def name(self) -> str:
def __init__(self) -> None:
self.event = threading.Event()

def set(self, pos: float) -> None:
@AsyncStatus.wrap
async def set(self, pos: float) -> None:
self.event.wait()
self.event.clear()

Expand Down

0 comments on commit 5b98fb0

Please sign in to comment.