From 8a8b8682d52ca7c4d2090c0d468841709f94a54f Mon Sep 17 00:00:00 2001 From: Peter Holloway Date: Thu, 29 Jan 2026 14:33:56 +0000 Subject: [PATCH] Improve logging when configuration includes no plans/devices --- src/blueapi/core/context.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/blueapi/core/context.py b/src/blueapi/core/context.py index 0d662d13a7..f7af3368cd 100644 --- a/src/blueapi/core/context.py +++ b/src/blueapi/core/context.py @@ -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: """ @@ -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, @@ -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: