Skip to content

Commit

Permalink
Remove ophyd_async_connect (#462)
Browse files Browse the repository at this point in the history
The device connection is now handled by device_instantiation in dodal.
This function also provides the option on whether to wait for
connection, so it is not needed here too.

Additionally it can lead to undefined (currently) behaviour if the
device is initially created with fake_with_ophyd_sim = True but then
later connected again by blueapi with fake_with_ophyd_sim = False.

This also leaves the sim property on BlueskyContext redundant so
that is removed too.

For full customisation and flexibility of lazy connect we need #440.

Fixes #461.
  • Loading branch information
joeshannon authored May 13, 2024
1 parent 22693e6 commit 4f1f44c
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 146 deletions.
11 changes: 1 addition & 10 deletions src/blueapi/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
from types import ModuleType, UnionType
from typing import Any, Generic, TypeVar, Union, get_args, get_origin, get_type_hints

from bluesky.run_engine import RunEngine, call_in_bluesky_event_loop
from bluesky.run_engine import RunEngine
from pydantic import create_model
from pydantic.fields import FieldInfo, ModelField

from blueapi.config import EnvironmentConfig, SourceKind
from blueapi.utils import (
BlueapiPlanModelConfig,
connect_ophyd_async_devices,
load_module_all,
)

Expand Down Expand Up @@ -45,7 +44,6 @@ class BlueskyContext:
plans: dict[str, Plan] = field(default_factory=dict)
devices: dict[str, Device] = field(default_factory=dict)
plan_functions: dict[str, PlanGenerator] = field(default_factory=dict)
sim: bool = field(default=False)

_reference_cache: dict[type, type] = field(default_factory=dict)

Expand Down Expand Up @@ -78,13 +76,6 @@ def with_config(self, config: EnvironmentConfig) -> None:
elif source.kind is SourceKind.DODAL:
self.with_dodal_module(mod)

call_in_bluesky_event_loop(
connect_ophyd_async_devices(
self.devices.values(),
self.sim,
)
)

def with_plan_module(self, module: ModuleType) -> None:
"""
Register all functions in the module supplied as plans.
Expand Down
4 changes: 1 addition & 3 deletions src/blueapi/service/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ def setup_handler(

handler = Handler(
config,
context=BlueskyContext(
sim=False,
),
context=BlueskyContext(),
)
handler.start()

Expand Down
2 changes: 0 additions & 2 deletions src/blueapi/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from .base_model import BlueapiBaseModel, BlueapiModelConfig, BlueapiPlanModelConfig
from .invalid_config_error import InvalidConfigError
from .modules import load_module_all
from .ophyd_async_connect import connect_ophyd_async_devices
from .serialization import serialize
from .thread_exception import handle_all_exceptions

Expand All @@ -14,5 +13,4 @@
"BlueapiModelConfig",
"BlueapiPlanModelConfig",
"InvalidConfigError",
"connect_ophyd_async_devices",
]
54 changes: 0 additions & 54 deletions src/blueapi/utils/ophyd_async_connect.py

This file was deleted.

77 changes: 0 additions & 77 deletions tests/utils/test_ophyd_async_connect.py

This file was deleted.

0 comments on commit 4f1f44c

Please sign in to comment.