From d28365e28b117968fb8eafdc16594646d1af1b5b Mon Sep 17 00:00:00 2001 From: Stanislaw Malinowski Date: Wed, 11 Sep 2024 14:52:08 +0100 Subject: [PATCH] fix some, indicate uncertain points --- docs/explanations/lifecycle.md | 2 +- errors.txt | 107 --------------------- src/blueapi/cli/cli.py | 1 - src/blueapi/core/bluesky_types.py | 2 +- src/blueapi/core/context.py | 4 +- src/blueapi/core/device_lookup.py | 7 +- src/blueapi/service/interface.py | 24 ++--- src/blueapi/service/main.py | 5 +- src/blueapi/service/runner.py | 4 +- src/blueapi/startup/example_plans.py | 15 +-- src/blueapi/utils/__init__.py | 1 - src/blueapi/worker/__init__.py | 1 - src/blueapi/worker/task_worker.py | 9 +- tests/conftest.py | 4 +- tests/unit_tests/cli/test_scratch.py | 2 + tests/unit_tests/core/test_context.py | 7 +- tests/unit_tests/service/test_interface.py | 2 +- tests/unit_tests/service/test_rest_api.py | 4 +- tests/unit_tests/worker/devices.py | 1 + 19 files changed, 50 insertions(+), 152 deletions(-) delete mode 100644 errors.txt diff --git a/docs/explanations/lifecycle.md b/docs/explanations/lifecycle.md index 862f3a754..98bd23af5 100644 --- a/docs/explanations/lifecycle.md +++ b/docs/explanations/lifecycle.md @@ -7,7 +7,7 @@ of being written, loaded and run. Take the following plan. import bluesky.plans as bp from blueapi.core import MsgGenerator - from dls_bluesky_core.core import inject + from dodal.common import inject from bluesky.protocols import Readable diff --git a/errors.txt b/errors.txt deleted file mode 100644 index ec730fb2e..000000000 --- a/errors.txt +++ /dev/null @@ -1,107 +0,0 @@ - -/scratch/xma12127/projects/forks/blueapi/src/blueapi/cli/cli.py - /scratch/xma12127/projects/forks/blueapi/src/blueapi/cli/cli.py:155:26 - error: Argument of type "Unknown | BasicAuthentication | None" cannot be assigned to parameter "auth" of type "BasicAuthentication | None" in function "__init__" (reportArgumentType) -/scratch/xma12127/projects/forks/blueapi/src/blueapi/client/client.py - /scratch/xma12127/projects/forks/blueapi/src/blueapi/client/client.py:48:26 - error: Argument of type "BasicAuthentication | None" cannot be assigned to parameter "auth" of type "BasicAuthentication | None" in function "__init__" (reportArgumentType) -/scratch/xma12127/projects/forks/blueapi/src/blueapi/core/context.py - /scratch/xma12127/projects/forks/blueapi/src/blueapi/core/context.py:149:15 - error: Argument of type "tuple[type, FieldInfo]" cannot be assigned to parameter "__doc__" of type "str | None" in function "create_model" - Type "tuple[type, FieldInfo]" is not assignable to type "str | None" - "tuple[type, FieldInfo]" is not assignable to "str" - "tuple[type, FieldInfo]" is not assignable to "None" (reportArgumentType) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/core/context.py:149:15 - error: Argument of type "tuple[type, FieldInfo]" cannot be assigned to parameter "__base__" of type "type[ModelT@create_model] | tuple[type[ModelT@create_model], ...]" in function "create_model" - Type "tuple[type, FieldInfo]" is not assignable to type "type[ModelT@create_model] | tuple[type[ModelT@create_model], ...]" - Type "tuple[type, FieldInfo]" is not assignable to type "type[ModelT@create_model]" - "tuple[type, FieldInfo]" is not assignable to "tuple[type[ModelT@create_model], ...]" - Tuple entry 1 is incorrect type - Type "type | FieldInfo" is not assignable to type "type[ModelT@create_model]" (reportArgumentType) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/core/context.py:149:15 - error: Argument of type "tuple[type, FieldInfo]" cannot be assigned to parameter "__module__" of type "str" in function "create_model" - "tuple[type, FieldInfo]" is not assignable to "str" (reportArgumentType) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/core/context.py:149:15 - error: Argument of type "tuple[type, FieldInfo]" cannot be assigned to parameter "__validators__" of type "dict[str, (...) -> Any] | None" in function "create_model" - Type "tuple[type, FieldInfo]" is not assignable to type "dict[str, (...) -> Any] | None" - "tuple[type, FieldInfo]" is not assignable to "dict[str, (...) -> Any]" - "tuple[type, FieldInfo]" is not assignable to "None" (reportArgumentType) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/core/context.py:149:15 - error: Argument of type "tuple[type, FieldInfo]" cannot be assigned to parameter "__cls_kwargs__" of type "dict[str, Any] | None" in function "create_model" - Type "tuple[type, FieldInfo]" is not assignable to type "dict[str, Any] | None" - "tuple[type, FieldInfo]" is not assignable to "dict[str, Any]" - "tuple[type, FieldInfo]" is not assignable to "None" (reportArgumentType) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/core/context.py:287:20 - error: Union requires two or more type arguments (reportInvalidTypeArguments) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/core/context.py:287:20 - error: Type "tuple[type, ...] | Any | type" is not assignable to return type "type" - Type "tuple[type, ...] | Any | type" is not assignable to type "type" - "UnionType" is not assignable to "type" (reportReturnType) -/scratch/xma12127/projects/forks/blueapi/src/blueapi/core/device_lookup.py - /scratch/xma12127/projects/forks/blueapi/src/blueapi/core/device_lookup.py:9:50 - warning: TypeVar "D" appears only once in generic function signature - Use "Device" instead (reportInvalidTypeVarUse) -/scratch/xma12127/projects/forks/blueapi/src/blueapi/service/interface.py - /scratch/xma12127/projects/forks/blueapi/src/blueapi/service/interface.py:57:70 - error: Argument of type "BasicAuthentication | None" cannot be assigned to parameter "auth" of type "BasicAuthentication | None" in function "__init__" (reportArgumentType) -/scratch/xma12127/projects/forks/blueapi/src/blueapi/service/main.py - /scratch/xma12127/projects/forks/blueapi/src/blueapi/service/main.py:165:44 - error: "plan_model" is possibly unbound (reportPossiblyUnboundVariable) -/scratch/xma12127/projects/forks/blueapi/src/blueapi/service/runner.py - /scratch/xma12127/projects/forks/blueapi/src/blueapi/service/runner.py:144:20 - error: ParamSpec "P" has no meaning in this context (reportGeneralTypeIssues) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/service/runner.py:144:28 - error: Type "(...) -> Unknown" is not assignable to declared type "(**P) -> T@_rpc" - Type "(...) -> Unknown" is not assignable to type "(**P) -> T@_rpc" (reportAssignmentType) -/scratch/xma12127/projects/forks/blueapi/src/blueapi/startup/example_plans.py - /scratch/xma12127/projects/forks/blueapi/src/blueapi/startup/example_plans.py:11:28 - error: Expression of type "str" cannot be assigned to parameter of type "Movable" - "str" is incompatible with protocol "Movable" - "set" is not present (reportArgumentType) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/startup/example_plans.py:12:25 - error: Expression of type "str" cannot be assigned to parameter of type "Movable" - "str" is incompatible with protocol "Movable" - "set" is not present (reportArgumentType) -/scratch/xma12127/projects/forks/blueapi/src/blueapi/startup/simmotor.py - /scratch/xma12127/projects/forks/blueapi/src/blueapi/startup/simmotor.py:30:19 - error: Argument of type "float" cannot be assigned to parameter "value" of type "int" in function "__init__" - "float" is not assignable to "int" (reportArgumentType) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/startup/simmotor.py:31:19 - error: Argument of type "float" cannot be assigned to parameter "delay" of type "int" in function "__init__" - "float" is not assignable to "int" (reportArgumentType) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/startup/simmotor.py:41:9 - error: Method "set" overrides class "SynAxis" in an incompatible manner - Return type mismatch: base method returns type "MoveStatus", override returns type "None" - "None" is not assignable to "MoveStatus" (reportIncompatibleMethodOverride) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/startup/simmotor.py:83:16 - error: Type "MoveStatus" is not assignable to return type "None" - "MoveStatus" is not assignable to "None" (reportReturnType) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/startup/simmotor.py:93:9 - error: Method "set" overrides class "SynAxis" in an incompatible manner - Return type mismatch: base method returns type "MoveStatus", override returns type "Status" - "Status" is not assignable to "MoveStatus" (reportIncompatibleMethodOverride) -/scratch/xma12127/projects/forks/blueapi/src/blueapi/utils/__init__.py - /scratch/xma12127/projects/forks/blueapi/src/blueapi/utils/__init__.py:10:5 - warning: "ConfigLoader" is specified in __all__ but is not present in module (reportUnsupportedDunderAll) -/scratch/xma12127/projects/forks/blueapi/src/blueapi/worker/__init__.py - /scratch/xma12127/projects/forks/blueapi/src/blueapi/worker/__init__.py:9:5 - warning: "Worker" is specified in __all__ but is not present in module (reportUnsupportedDunderAll) -/scratch/xma12127/projects/forks/blueapi/src/blueapi/worker/task_worker.py - /scratch/xma12127/projects/forks/blueapi/src/blueapi/worker/task_worker.py:98:54 - error: Argument of type "LoggingPropertyMachine | ProxyString | str" cannot be assigned to parameter "bluesky_state" of type "RawRunEngineState" in function "from_bluesky_state" (reportArgumentType) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/worker/task_worker.py:129:40 - error: Argument of type "str | None" cannot be assigned to parameter "reason" of type "str" in function "abort" - Type "str | None" is not assignable to type "str" - "None" is not assignable to "str" (reportArgumentType) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/worker/task_worker.py:194:44 - error: "sub" is possibly unbound (reportPossiblyUnboundVariable) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/worker/task_worker.py:232:30 - error: Cannot assign to attribute "state_hook" for class "RunEngine" - Expression of type "(raw_new_state: RawRunEngineState, raw_old_state: RawRunEngineState | None = None) -> None" cannot be assigned to attribute "state_hook" of class "RunEngine" - "function" is not assignable to "None" (reportAttributeAccessIssue) - /scratch/xma12127/projects/forks/blueapi/src/blueapi/worker/task_worker.py:235:34 - error: Cannot assign to attribute "waiting_hook" for class "RunEngine" - Expression of type "(statuses: Iterable[Status] | None) -> None" cannot be assigned to attribute "waiting_hook" of class "RunEngine" - "function" is not assignable to "None" (reportAttributeAccessIssue) -/scratch/xma12127/projects/forks/blueapi/tests/conftest.py - /scratch/xma12127/projects/forks/blueapi/tests/conftest.py:5:21 - error: "RunEngine" is not exported from module "bluesky" - Import from "bluesky.run_engine" instead (reportPrivateImportUsage) - /scratch/xma12127/projects/forks/blueapi/tests/conftest.py:6:32 - error: "TransitionError" is not exported from module "bluesky.run_engine" (reportPrivateImportUsage) -/scratch/xma12127/projects/forks/blueapi/tests/unit_tests/cli/test_scratch.py - /scratch/xma12127/projects/forks/blueapi/tests/unit_tests/cli/test_scratch.py:17:11 - error: Return type of generator function must be compatible with "Generator[Path, Any, Any]" - "Generator[Path, Unknown, Unknown]" is not assignable to "Path" (reportReturnType) - /scratch/xma12127/projects/forks/blueapi/tests/unit_tests/cli/test_scratch.py:26:11 - error: Return type of generator function must be compatible with "Generator[Path, Any, Any]" - "Generator[Path, Unknown, Unknown]" is not assignable to "Path" (reportReturnType) -/scratch/xma12127/projects/forks/blueapi/tests/unit_tests/core/test_context.py - /scratch/xma12127/projects/forks/blueapi/tests/unit_tests/core/test_context.py:51:40 - error: Expression of type "str" cannot be assigned to parameter of type "Movable" - "str" is incompatible with protocol "Movable" - "set" is not present (reportArgumentType) - /scratch/xma12127/projects/forks/blueapi/tests/unit_tests/core/test_context.py:59:24 - error: Expression of type "list[str]" cannot be assigned to parameter of type "list[Movable]" - "list[str]" is not assignable to "list[Movable]" - Type parameter "_T@list" is invariant, but "str" is not the same as "Movable" - Consider switching from "list" to "Sequence" which is covariant (reportArgumentType) -/scratch/xma12127/projects/forks/blueapi/tests/unit_tests/service/test_rest_api.py - /scratch/xma12127/projects/forks/blueapi/tests/unit_tests/service/test_rest_api.py:28:10 - error: Object of type "tuple[_patch_default_new]" cannot be used with "with" because it does not implement __enter__ - Attribute "__enter__" is unknown (reportGeneralTypeIssues) - /scratch/xma12127/projects/forks/blueapi/tests/unit_tests/service/test_rest_api.py:28:10 - error: Object of type "tuple[_patch_default_new]" cannot be used with "with" because it does not implement __exit__ (reportGeneralTypeIssues) -/scratch/xma12127/projects/forks/blueapi/tests/unit_tests/worker/devices.py - /scratch/xma12127/projects/forks/blueapi/tests/unit_tests/worker/devices.py:44:16 - error: Type "AdditionalUpdateStatus" is not assignable to return type "Status" - "AdditionalUpdateStatus" is incompatible with protocol "Status" - "exception" is an incompatible type - Type "(timeout: Unknown | None = None) -> (StatusTimeoutError | Exception | type[Exception] | None)" is not assignable to type "(timeout: float | None = 0) -> (BaseException | None)" - Function return type "StatusTimeoutError | Exception | type[Exception] | None" is incompatible with type "BaseException | None" - "Status" is not assignable to "AdditionalUpdateStatus" - "Status" is not assignable to "AdditionalUpdateStatus" (reportReturnType) -34 errors, 3 warnings, 0 informations \ No newline at end of file diff --git a/src/blueapi/cli/cli.py b/src/blueapi/cli/cli.py index 51408422e..eadfdb348 100644 --- a/src/blueapi/cli/cli.py +++ b/src/blueapi/cli/cli.py @@ -19,7 +19,6 @@ from blueapi.client.rest import BlueskyRemoteControlError from blueapi.config import ( ApplicationConfig, - BasicAuthentication, ConfigLoader, StompConfig, ) diff --git a/src/blueapi/core/bluesky_types.py b/src/blueapi/core/bluesky_types.py index 1a2978213..845a9a05d 100644 --- a/src/blueapi/core/bluesky_types.py +++ b/src/blueapi/core/bluesky_types.py @@ -24,7 +24,7 @@ Triggerable, WritesExternalAssets, ) -from dls_bluesky_core.core import MsgGenerator, PlanGenerator +from dodal.common import MsgGenerator, PlanGenerator from ophyd_async.core import Device as AsyncDevice from pydantic import BaseModel, Field diff --git a/src/blueapi/core/context.py b/src/blueapi/core/context.py index 7db7370ca..bdb9df1f7 100644 --- a/src/blueapi/core/context.py +++ b/src/blueapi/core/context.py @@ -146,7 +146,7 @@ def my_plan(a: int, b: str): model = create_model( plan.__name__, __config__=BlueapiPlanModelConfig, - **self._type_spec_for_function(plan), + **self._type_spec_for_function(plan), # type: ignore ) self.plans[plan.__name__] = Plan( name=plan.__name__, model=model, description=plan.__doc__ @@ -284,7 +284,7 @@ def _convert_type(self, typ: type | Any) -> type: root = get_origin(typ) if root == UnionType: root = Union - return root[new_types] if root else typ + return root[new_types] # type: ignore return typ diff --git a/src/blueapi/core/device_lookup.py b/src/blueapi/core/device_lookup.py index 1bace1676..72dff32f0 100644 --- a/src/blueapi/core/device_lookup.py +++ b/src/blueapi/core/device_lookup.py @@ -1,12 +1,9 @@ -from typing import Any, TypeVar +from typing import Any from .bluesky_types import Device, is_bluesky_compatible_device -#: Device obeying Bluesky protocols -D = TypeVar("D", bound=Device) - -def find_component(obj: Any, addr: list[str]) -> D | None: +def find_component(obj: Any, addr: list[str]) -> Device | None: """ Best effort function to locate a child device, either in a dictionary of devices or a device with child attributes. diff --git a/src/blueapi/service/interface.py b/src/blueapi/service/interface.py index 914639c62..69d3da4f3 100644 --- a/src/blueapi/service/interface.py +++ b/src/blueapi/service/interface.py @@ -6,7 +6,7 @@ from bluesky_stomp.messaging import StompClient from bluesky_stomp.models import Broker, DestinationBase, MessageTopic -from blueapi.config import ApplicationConfig +from blueapi.config import ApplicationConfig, StompConfig from blueapi.core.context import BlueskyContext from blueapi.core.event import EventStream from blueapi.service.model import DeviceModel, PlanModel, WorkerTask @@ -49,12 +49,14 @@ def worker() -> TaskWorker: @lru_cache -def messaging_template() -> StompClient | None: - stomp_config = config().stomp +def cached_stomp_client() -> StompClient | None: + stomp_config: StompConfig | None = config().stomp if stomp_config is not None: - template = StompClient.for_broker( + client = StompClient.for_broker( broker=Broker( - host=stomp_config.host, port=stomp_config.port, auth=stomp_config.auth + host=stomp_config.host, + port=stomp_config.port, + auth=stomp_config.auth, # type: ignore ) ) @@ -68,8 +70,8 @@ def messaging_template() -> StompClient | None: task_worker.data_events: event_topic, } ) - template.connect() - return template + client.connect() + return client else: return None @@ -83,16 +85,16 @@ def setup(config: ApplicationConfig) -> None: logging.basicConfig(level=config.logging.level) worker() - messaging_template() + cached_stomp_client() def teardown() -> None: worker().stop() - if (template := messaging_template()) is not None: + if (template := cached_stomp_client()) is not None: template.disconnect() context.cache_clear() worker.cache_clear() - messaging_template.cache_clear() + cached_stomp_client.cache_clear() def _publish_event_streams( @@ -104,7 +106,7 @@ def _publish_event_streams( def _publish_event_stream(stream: EventStream, destination: DestinationBase) -> None: def forward_message(event: Any, correlation_id: str | None) -> None: - if (template := messaging_template()) is not None: + if (template := cached_stomp_client()) is not None: template.send(destination, event, None, correlation_id=correlation_id) stream.subscribe(forward_message) diff --git a/src/blueapi/service/main.py b/src/blueapi/service/main.py index 0a5c25070..59a9bcfaf 100644 --- a/src/blueapi/service/main.py +++ b/src/blueapi/service/main.py @@ -148,9 +148,10 @@ def submit_task( task: Task = Body(..., example=example_task), runner: WorkerDispatcher = Depends(_runner), ): + plan_model: PlanModel | None = None """Submit a task to the worker.""" + plan_model = runner.run(interface.get_plan, task.name) try: - plan_model = runner.run(interface.get_plan, task.name) task_id: str = runner.run(interface.submit_task, task) response.headers["Location"] = f"{request.url}/{task_id}" return TaskResponse(task_id=task_id) @@ -161,7 +162,7 @@ def submit_task( ) error_detail_response = f""" Input validation failed: {formatted_errors}, - suppplied params {task.params}, + supplied params {task.params}, do not match the expected params: {plan_model.parameter_schema} """ raise HTTPException( diff --git a/src/blueapi/service/runner.py b/src/blueapi/service/runner.py index e122bf7d7..815bd9727 100644 --- a/src/blueapi/service/runner.py +++ b/src/blueapi/service/runner.py @@ -141,9 +141,9 @@ def _rpc( **kwargs: Any, ) -> T: mod = import_module(module_name) - func: Callable[P, T] = _validate_function( + func: Callable[..., T] = _validate_function( mod.__dict__.get(function_name, None), function_name - ) + ) # type: ignore value = func(*args, **kwargs) return _valid_return(value, expected_type) diff --git a/src/blueapi/startup/example_plans.py b/src/blueapi/startup/example_plans.py index b3d969521..716874d77 100644 --- a/src/blueapi/startup/example_plans.py +++ b/src/blueapi/startup/example_plans.py @@ -1,15 +1,16 @@ +import bluesky.plan_stubs as bps +from bluesky.plans import count from bluesky.protocols import Movable, Readable -from dls_bluesky_core.core import inject -from dls_bluesky_core.plans import count -from dls_bluesky_core.stubs import move +from dodal.common import MsgGenerator, inject -from blueapi.core import MsgGenerator +TEMP: Movable = inject("sample_temperature") +PRESS: Movable = inject("sample_pressure") def stp_snapshot( detectors: list[Readable], - temperature: Movable = inject("sample_temperature"), - pressure: Movable = inject("sample_pressure"), + temperature: Movable = TEMP, + pressure: Movable = PRESS, ) -> MsgGenerator: """ Moves devices for pressure and temperature (defaults fetched from the context) @@ -26,5 +27,5 @@ def stp_snapshot( Yields: Iterator[MsgGenerator]: Bluesky messages """ - yield from move({temperature: 0, pressure: 10**5}) + yield from bps.mv({temperature: 0, pressure: 10**5}) yield from count(detectors, 1) diff --git a/src/blueapi/utils/__init__.py b/src/blueapi/utils/__init__.py index b871f842a..c81762542 100644 --- a/src/blueapi/utils/__init__.py +++ b/src/blueapi/utils/__init__.py @@ -7,7 +7,6 @@ __all__ = [ "handle_all_exceptions", "load_module_all", - "ConfigLoader", "serialize", "BlueapiBaseModel", "BlueapiModelConfig", diff --git a/src/blueapi/worker/__init__.py b/src/blueapi/worker/__init__.py index 7862912cc..85ae49b45 100644 --- a/src/blueapi/worker/__init__.py +++ b/src/blueapi/worker/__init__.py @@ -6,7 +6,6 @@ __all__ = [ "TaskWorker", "Task", - "Worker", "WorkerEvent", "WorkerState", "StatusView", diff --git a/src/blueapi/worker/task_worker.py b/src/blueapi/worker/task_worker.py index 77d2d4f98..7b68aaf4d 100644 --- a/src/blueapi/worker/task_worker.py +++ b/src/blueapi/worker/task_worker.py @@ -126,7 +126,8 @@ def cancel_active_task( # We only allow this method to be called if a Plan is active raise TransitionError("Attempted to cancel while no active Task") if failure: - self._ctx.run_engine.abort(reason) + default_reason = "Task failed for unknown reason" + self._ctx.run_engine.abort(reason or default_reason) else: self._ctx.run_engine.stop() return self._current.task_id @@ -181,8 +182,8 @@ def mark_task_as_started(event: WorkerEvent, _: str | None) -> None: task_started.set() LOGGER.info(f"Submitting: {trackable_task}") + sub = self.worker_events.subscribe(mark_task_as_started) try: - sub = self.worker_events.subscribe(mark_task_as_started) self._task_channel.put_nowait(trackable_task) task_started.wait(timeout=5.0) if not task_started.is_set(): @@ -262,7 +263,9 @@ def _cycle(self) -> None: next_task: TrackableTask | KillSignal = self._task_channel.get() if isinstance(next_task, TrackableTask): LOGGER.info(f"Got new task: {next_task}") - self._current = next_task # Informing type checker that the task is not None + self._current = ( + next_task # Informing type checker that the task is not None + ) self._current.is_pending = False self._current.task.do_task(self._ctx) elif isinstance(next_task, KillSignal): diff --git a/tests/conftest.py b/tests/conftest.py index 838d4b219..f2631b453 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,8 +2,8 @@ # Based on https://docs.pytest.org/en/latest/example/simple.html#control-skipping-of-tests-according-to-command-line-option # noqa: E501 import pytest -from bluesky import RunEngine -from bluesky.run_engine import TransitionError +from bluesky.run_engine import RunEngine +from super_state_machine.errors import TransitionError @pytest.fixture(scope="function") diff --git a/tests/unit_tests/cli/test_scratch.py b/tests/unit_tests/cli/test_scratch.py index 7e4ca3b9e..6e015d2c7 100644 --- a/tests/unit_tests/cli/test_scratch.py +++ b/tests/unit_tests/cli/test_scratch.py @@ -14,6 +14,7 @@ @pytest.fixture def directory_path() -> Path: # type: ignore temporary_directory = TemporaryDirectory() + # todo what does the yield do? yield Path(temporary_directory.name) temporary_directory.cleanup() @@ -23,6 +24,7 @@ def file_path(directory_path: Path) -> Path: # type: ignore file_path = directory_path / str(uuid.uuid4()) with file_path.open("w") as stream: stream.write("foo") + # todo what does the yield do? yield file_path os.remove(file_path) diff --git a/tests/unit_tests/core/test_context.py b/tests/unit_tests/core/test_context.py index c7b1ad8ef..e54a4a329 100644 --- a/tests/unit_tests/core/test_context.py +++ b/tests/unit_tests/core/test_context.py @@ -5,7 +5,7 @@ import pytest from bluesky.protocols import Descriptor, Movable, Readable, Reading, SyncOrAsync -from dls_bluesky_core.core import MsgGenerator, PlanGenerator, inject +from dodal.common import MsgGenerator, PlanGenerator, inject from ophyd.sim import SynAxis, SynGauss from pydantic import TypeAdapter, ValidationError from pytest import LogCaptureFixture @@ -48,7 +48,10 @@ def has_typeless_params(foo, bar) -> MsgGenerator: # type: ignore ... -def has_default_reference(m: Movable = inject(SIM_MOTOR_NAME)) -> MsgGenerator: +MOTOR: Movable = inject(SIM_MOTOR_NAME) + + +def has_default_reference(m: Movable = MOTOR) -> MsgGenerator: yield from [] diff --git a/tests/unit_tests/service/test_interface.py b/tests/unit_tests/service/test_interface.py index 86dd2e5c1..617a91935 100644 --- a/tests/unit_tests/service/test_interface.py +++ b/tests/unit_tests/service/test_interface.py @@ -288,4 +288,4 @@ def test_stomp_config(template: StompClient): "blueapi.service.interface.StompClient.for_broker", return_value=template ): interface.set_config(ApplicationConfig(stomp=StompConfig())) - assert interface.messaging_template() is not None + assert interface.cached_stomp_client() is not None diff --git a/tests/unit_tests/service/test_rest_api.py b/tests/unit_tests/service/test_rest_api.py index 6bb08cb01..c62975c44 100644 --- a/tests/unit_tests/service/test_rest_api.py +++ b/tests/unit_tests/service/test_rest_api.py @@ -25,9 +25,7 @@ @pytest.fixture def client() -> Iterator[TestClient]: - with ( - patch("blueapi.service.interface.worker"), - ): + with patch("blueapi.service.interface.worker"): main.setup_runner(use_subprocess=False) yield TestClient(main.app) main.teardown_runner() diff --git a/tests/unit_tests/worker/devices.py b/tests/unit_tests/worker/devices.py index 7d34fe6e5..aeee192b9 100644 --- a/tests/unit_tests/worker/devices.py +++ b/tests/unit_tests/worker/devices.py @@ -41,6 +41,7 @@ def _run_callbacks(self) -> None: class AdditionalStatusDevice(Device, Movable): def set(self, value: float) -> Status: status = AdditionalUpdateStatus(self) + # todo here again the ophyd issue return status