Skip to content

Commit 65fefad

Browse files
committed
Minor changes from PR comments
Rename ensure_connected to check_connected
1 parent 5d50efe commit 65fefad

5 files changed

Lines changed: 15 additions & 17 deletions

File tree

helm/blueapi/config_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@
9292
"title": "Name",
9393
"type": "string"
9494
},
95-
"ensure_connected": {
95+
"check_connected": {
9696
"default": false,
9797
"description": "If true, all devices must be successfully connected at startup.",
98-
"title": "Ensure Connected",
98+
"title": "Check Connected",
9999
"type": "boolean"
100100
}
101101
},

helm/blueapi/values.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,8 @@
510510
"module"
511511
],
512512
"properties": {
513-
"ensure_connected": {
514-
"title": "Ensure Connected",
513+
"check_connected": {
514+
"title": "Check Connected",
515515
"description": "If true, all devices must be successfully connected at startup.",
516516
"default": false,
517517
"type": "boolean"

src/blueapi/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class DeviceManagerSource(Source):
8383
name: str = Field(
8484
default="devices", description="Name of the device manager in the module"
8585
)
86-
ensure_connected: bool = Field(
86+
check_connected: bool = Field(
8787
default=False,
8888
description="If true, all devices must be successfully connected at startup.",
8989
)

src/blueapi/core/context.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,19 +215,18 @@ def with_config(self, config: EnvironmentConfig) -> None:
215215
case DodalSource(mock=mock):
216216
self.with_dodal_module(mod, mock=mock)
217217
case DeviceManagerSource(
218-
mock=mock, name=name, ensure_connected=ensure_connected
218+
mock=mock, name=name, check_connected=check_connected
219219
):
220220
manager = getattr(mod, name)
221221
if not isinstance(manager, DeviceManager):
222222
raise ValueError(
223223
f"{name} in module {mod} is not a device manager"
224224
)
225-
device_map, error_map = self.with_device_manager(manager, mock)
226-
if ensure_connected and error_map:
227-
raise ExceptionGroup(
228-
"Errors occurred while connecting the following devices: "
229-
f"{', '.join(error_map.keys())}",
230-
list(error_map.values()),
225+
_, error_map = self.with_device_manager(manager, mock)
226+
if check_connected and error_map:
227+
raise RuntimeError(
228+
"Errors occurred while building/connecting the following "
229+
f"devices: {', '.join(error_map)}",
231230
)
232231

233232
def with_plan_module(self, module: ModuleType) -> None:

tests/unit_tests/core/test_context.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,16 +443,15 @@ def test_with_config_passes_mock_to_with_dodal_module(
443443
def test_with_config_raises_exception_group_on_connection_errors_when_ensure_connected(
444444
empty_context: BlueskyContext, beamline_with_connection_and_build_errors: None
445445
):
446-
with pytest.raises(ExceptionGroup, match="Errors occurred while connecting.*") as e:
446+
with pytest.raises(
447+
RuntimeError, match="Errors occurred while building/connecting.*"
448+
):
447449
empty_context.with_config(
448450
EnvironmentConfig(
449-
sources=[DeviceManagerSource(module="foo.bar", ensure_connected=True)]
451+
sources=[DeviceManagerSource(module="foo.bar", check_connected=True)]
450452
)
451453
)
452454

453-
assert e.value.exceptions[0].args[0] == "Simulated Build Error"
454-
assert e.value.exceptions[1].args[0] == "Simulated Connection Error"
455-
456455

457456
def test_with_config_ignores_build_connect_exceptions_by_default(
458457
empty_context: BlueskyContext, beamline_with_connection_and_build_errors: None

0 commit comments

Comments
 (0)