Skip to content
Merged
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions src/blueapi/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,35 @@ def with_config(self, config: EnvironmentConfig) -> None:

match source:
case PlanSource():
LOGGER.info("Including plans from %s", source.module)
self.with_plan_module(mod)
case DeviceSource():
LOGGER.info("Including devices from %s", source.module)
self.with_device_module(mod)
case DodalSource(mock=mock):
LOGGER.info(
"Including devices from 'dodal' source %s", source.module
)
self.with_dodal_module(mod, mock=mock)
case DeviceManagerSource(mock=mock, name=name):
LOGGER.info(
"Including devices from 'deviceManager' source %s:%s",
source.module,
name,
)
manager = getattr(mod, name)
if not isinstance(manager, DeviceManager):
raise ValueError(
f"{name} in module {mod} is not a device manager"
)
self.with_device_manager(manager, mock)
if not self.devices:
LOGGER.warning(
"Context had no devices after loading environment - are all modules "
"included and marked with the correct 'kind'?"
)
if not self.plans:
LOGGER.warning("Context had no plans registered after loading environment")

def with_plan_module(self, module: ModuleType) -> None:
"""
Expand Down Expand Up @@ -273,6 +290,12 @@ def with_device_manager(self, manager: DeviceManager, mock: bool = False):
f"{len(errs)} errors while connecting devices",
exc_info=NotConnectedError(errs),
)
if not (
build_result.devices
or build_result.build_errors
or build_result.connection_errors
):
LOGGER.warning("Device manager did not build any devices")
return build_result.devices, {
**build_result.build_errors,
**build_result.connection_errors,
Expand Down Expand Up @@ -311,6 +334,8 @@ def with_dodal_module(
f"{len(exceptions)} exceptions occurred while instantiating devices"
)
LOGGER.exception(NotConnectedError(exceptions))
elif not devices:
LOGGER.warning("No devices were loaded from dodal module %s", module)
return devices, exceptions

def register_plan(self, plan: PlanGenerator) -> PlanGenerator:
Expand Down
Loading