From 154093d361147fd218ff7bc0a8c8f83478e77520 Mon Sep 17 00:00:00 2001 From: yannachen Date: Thu, 21 Nov 2024 09:03:08 -0600 Subject: [PATCH 1/3] Special handling of warnings for the pcds aggregate signal. --- src/ophydregistry/registry.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ophydregistry/registry.py b/src/ophydregistry/registry.py index 379544c..6ed447e 100644 --- a/src/ophydregistry/registry.py +++ b/src/ophydregistry/registry.py @@ -550,7 +550,11 @@ def register( try: name = component.name except AttributeError: - log.info(f"Skipping unnamed component {component}") + msg = f"Skipping unnamed component {component}" + if isinstance(component, _AggregateSignalState): + log.debug(msg) + else: + log.info(msg) return component # Register this object with Typhos if self.use_typhos: From fc165c9ea468dbbfa806aa424cae61e8c6e120ae Mon Sep 17 00:00:00 2001 From: yannachen Date: Thu, 21 Nov 2024 21:03:52 -0600 Subject: [PATCH 2/3] Improved handling of devices where *name* is "". --- src/ophydregistry/registry.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ophydregistry/registry.py b/src/ophydregistry/registry.py index 6ed447e..705537b 100644 --- a/src/ophydregistry/registry.py +++ b/src/ophydregistry/registry.py @@ -575,6 +575,10 @@ def register( msg = f"Ignoring readback with duplicate name: '{name}'" log.debug(msg) return component + elif old_obj is component: + msg = f"Ignoring previously registered component: '{name}'" + log.debug(msg) + return component else: msg = f"Ignoring component with duplicate name: '{name}'" is_duplicate = True @@ -585,8 +589,14 @@ def register( log.debug(msg) # Register this component log.debug(f"Registering {name}") - # Create a set for this device name if it doesn't exist - self._objects_by_name[component.name] = component + # Check if this device was previously registered with a + # different name + old_keys = [key for key, val in self._objects_by_name.items() if val is component] + for old_key in old_keys: + del self._objects_by_name[old_key] + # Register by name + if component.name != "": + self._objects_by_name[component.name] = component # Create a set for this device's labels if it doesn't exist if labels is None: ophyd_labels = getattr(component, "_ophyd_labels_", []) From 16760e09f5fd61401547da740b12c203157b81e0 Mon Sep 17 00:00:00 2001 From: Mark Wolfman Date: Thu, 21 Nov 2024 21:22:23 -0600 Subject: [PATCH 3/3] Black linting. --- src/ophydregistry/registry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ophydregistry/registry.py b/src/ophydregistry/registry.py index 705537b..ea2a417 100644 --- a/src/ophydregistry/registry.py +++ b/src/ophydregistry/registry.py @@ -591,7 +591,9 @@ def register( log.debug(f"Registering {name}") # Check if this device was previously registered with a # different name - old_keys = [key for key, val in self._objects_by_name.items() if val is component] + old_keys = [ + key for key, val in self._objects_by_name.items() if val is component + ] for old_key in old_keys: del self._objects_by_name[old_key] # Register by name