diff --git a/src/pandablocks_ioc/ioc.py b/src/pandablocks_ioc/ioc.py index 455c7e3c..581a2d3e 100644 --- a/src/pandablocks_ioc/ioc.py +++ b/src/pandablocks_ioc/ioc.py @@ -269,7 +269,6 @@ async def introspect_panda( def extract_label_from_metadata(block_name_number, field_name: str): - # # Parse *METADATA.LABEL_ into "" key and # ":LABEL" value if block_name_number.startswith("*METADATA") and field_name.startswith("LABEL_"): @@ -2101,6 +2100,21 @@ async def update( for field, value in changes.values.items(): field = PandAName(field) + field = panda_to_epics_name(field) + + if block_label := extract_label_from_metadata( + *field.split(":", maxsplit=1) + ): + no_trailing_number_regex = r"\d*$" + block_label_no_number = ( + f"{re.sub(no_trailing_number_regex, '', block_label)}:LABEL" + ) + block_label = f"{block_label}:LABEL" + + if block_label_no_number in all_records: + field = block_label_no_number + elif block_label in all_records: + field = block_label if field not in all_records: logging.error(