From a236d26cbb54dc27c8d9243b5c9d7e1f2ff1ecad Mon Sep 17 00:00:00 2001 From: "Tom C (DLS)" <101418278+coretl@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:00:58 +0000 Subject: [PATCH] Add a hint to PandA if we can't find a block (#668) * Add a hint to PandA if we can't find a block * Address review comments --- .github/PULL_REQUEST_TEMPLATE/pull_request_template.md | 2 ++ src/ophyd_async/epics/core/_pvi_connector.py | 6 ++++-- src/ophyd_async/fastcs/core.py | 4 ++-- src/ophyd_async/fastcs/panda/_hdf_panda.py | 5 ++++- tests/fastcs/panda/test_panda_connect.py | 6 ++++-- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md index 8200afe5c4..37552994d5 100644 --- a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -6,3 +6,5 @@ Fixes #ISSUE ### Checks for reviewer - [ ] Would the PR title make sense to a user on a set of release notes +- [ ] If the change requires a bump in an IOC version, is that specified in a `##Changes` section in the body of the PR +- [ ] If the change requires a bump in the PandABlocks-ioc version, is the `ophyd_async.fastcs.panda._hdf_panda.MINIMUM_PANDA_IOC` variable updated to match diff --git a/src/ophyd_async/epics/core/_pvi_connector.py b/src/ophyd_async/epics/core/_pvi_connector.py index 1c5c0eceb6..712b58d2e9 100644 --- a/src/ophyd_async/epics/core/_pvi_connector.py +++ b/src/ophyd_async/epics/core/_pvi_connector.py @@ -32,10 +32,11 @@ def _get_signal_details(entry: Entry) -> tuple[type[Signal], str, str]: class PviDeviceConnector(DeviceConnector): - def __init__(self, prefix: str = "") -> None: + def __init__(self, prefix: str = "", error_hint: str = "") -> None: # TODO: what happens if we get a leading "pva://" here? self.prefix = prefix self.pvi_pv = prefix + "PVI" + self.error_hint = error_hint def create_children_from_annotations(self, device: Device): if not hasattr(self, "filler"): @@ -85,7 +86,8 @@ async def connect_real( if e: self._fill_child(name, e, i) # Check that all the requested children have been filled - self.filler.check_filled(f"{self.pvi_pv}: {entries}") + suffix = f"\n{self.error_hint}" if self.error_hint else "" + self.filler.check_filled(f"{self.pvi_pv}: {entries}{suffix}") # Set the name of the device to name all children device.set_name(device.name) return await super().connect_real(device, timeout, force_reconnect) diff --git a/src/ophyd_async/fastcs/core.py b/src/ophyd_async/fastcs/core.py index d7561c7578..07e6581164 100644 --- a/src/ophyd_async/fastcs/core.py +++ b/src/ophyd_async/fastcs/core.py @@ -2,8 +2,8 @@ from ophyd_async.epics.core import PviDeviceConnector -def fastcs_connector(device: Device, uri: str) -> DeviceConnector: +def fastcs_connector(device: Device, uri: str, error_hint: str = "") -> DeviceConnector: # TODO: add Tango support based on uri scheme - connector = PviDeviceConnector(uri) + connector = PviDeviceConnector(uri, error_hint) connector.create_children_from_annotations(device) return connector diff --git a/src/ophyd_async/fastcs/panda/_hdf_panda.py b/src/ophyd_async/fastcs/panda/_hdf_panda.py index f75403bbb3..3c33611aaa 100644 --- a/src/ophyd_async/fastcs/panda/_hdf_panda.py +++ b/src/ophyd_async/fastcs/panda/_hdf_panda.py @@ -9,6 +9,8 @@ from ._control import PandaPcapController from ._writer import PandaHDFWriter +MINIMUM_PANDA_IOC = "0.11.4" + class HDFPanda(CommonPandaBlocks, StandardDetector): def __init__( @@ -18,8 +20,9 @@ def __init__( config_sigs: Sequence[SignalR] = (), name: str = "", ): + error_hint = f"Is PandABlocks-ioc at least version {MINIMUM_PANDA_IOC}?" # This has to be first so we make self.pcap - connector = fastcs_connector(self, prefix) + connector = fastcs_connector(self, prefix, error_hint) controller = PandaPcapController(pcap=self.pcap) writer = PandaHDFWriter( path_provider=path_provider, diff --git a/tests/fastcs/panda/test_panda_connect.py b/tests/fastcs/panda/test_panda_connect.py index a5a88d7d87..e395ef1ca4 100644 --- a/tests/fastcs/panda/test_panda_connect.py +++ b/tests/fastcs/panda/test_panda_connect.py @@ -56,7 +56,9 @@ class CommonPandaBlocksNoData(Device): class Panda(CommonPandaBlocksNoData): def __init__(self, uri: str, name: str = ""): - super().__init__(name=name, connector=fastcs_connector(self, uri)) + super().__init__( + name=name, connector=fastcs_connector(self, uri, "Is it ok?") + ) yield Panda @@ -124,7 +126,7 @@ async def test_panda_with_missing_blocks(panda_pva, panda_t): match=re.escape( "mypanda: cannot provision ['pcap'] from PANDAQSRVI:PVI: " "{'pulse': [None, {'d': 'PANDAQSRVI:PULSE1:PVI'}]," - " 'seq': [None, {'d': 'PANDAQSRVI:SEQ1:PVI'}]}" + " 'seq': [None, {'d': 'PANDAQSRVI:SEQ1:PVI'}]}\nIs it ok?" ), ): await panda.connect()