diff --git a/src/calng/base_correction.py b/src/calng/base_correction.py index b461c88cf365a8ff4ffaa1cecbbc917ea8adb32e..de7e991083a6e294a82f13ea38799475b2f10fbc 100644 --- a/src/calng/base_correction.py +++ b/src/calng/base_correction.py @@ -1043,7 +1043,7 @@ def add_addon_nodes(schema, device_class, prefix="addons"): addon.load() for addon in entry_points().select().get("calng.correction_addon", []) if not addon.extras - or det_name in (extra[0] for extra in addon.extras) + or det_name in addon.extras ] for addon_class in device_class._available_addons: diff --git a/src/calng/corrections/Gotthard2Correction.py b/src/calng/corrections/Gotthard2Correction.py index 386aafc7d8d5d1a990c04f04afa5412d97e1cb44..84dc79e61d46e5b6b9ddec35935358945d2dfb1a 100644 --- a/src/calng/corrections/Gotthard2Correction.py +++ b/src/calng/corrections/Gotthard2Correction.py @@ -319,6 +319,7 @@ class Gotthard2Correction(base_correction.BaseCorrection): def expectedParameters(cls, expected): cls._calcat_friend_class.add_schema(expected) cls._kernel_runner_class.add_schema(expected) + base_correction.add_addon_nodes(expected, cls) PreviewFriend.add_schema(expected, cls._preview_outputs) ( OUTPUT_CHANNEL(expected) diff --git a/src/calng/corrections/JungfrauCorrection.py b/src/calng/corrections/JungfrauCorrection.py index c51cbe0865be0c9da5034f11785a70f219edf754..1d9cb0c4c79e7e43fbc585a62367b88f35377143 100644 --- a/src/calng/corrections/JungfrauCorrection.py +++ b/src/calng/corrections/JungfrauCorrection.py @@ -461,6 +461,7 @@ class JungfrauCorrection(base_correction.BaseCorrection): def expectedParameters(cls, expected): cls._calcat_friend_class.add_schema(expected) JungfrauBaseRunner.add_schema(expected) + base_correction.add_addon_nodes(expected, cls) PreviewFriend.add_schema(expected, cls._preview_outputs) ( OUTPUT_CHANNEL(expected) diff --git a/tests/test_addon_system.py b/tests/test_addon_system.py new file mode 100644 index 0000000000000000000000000000000000000000..0a2ece76857bee2b894c94914fb0bb972889bc99 --- /dev/null +++ b/tests/test_addon_system.py @@ -0,0 +1,44 @@ +from karabo.bound import Configurator, Schema + +from calng.correction_addons import litpixel_counter, random_frames +from calng.corrections import ( + AgipdCorrection, + DsscCorrection, + Epix100Correction, + Gotthard2Correction, + JungfrauCorrection, + LpdCorrection, + LpdminiCorrection, + PnccdCorrection, +) + + +def test_available_addons(): + all_device_classes = [ + AgipdCorrection, + DsscCorrection, + Epix100Correction, + Gotthard2Correction, + JungfrauCorrection, + LpdCorrection, + LpdminiCorrection, + PnccdCorrection, + ] + actual_classes = [ + getattr(cls, cls.__name__.rpartition(".")[-1]) for cls in all_device_classes + ] + + configurator = Configurator("PythonDevice") + for cls in actual_classes: + schema_hash = configurator.getSchema(cls).getParameterHash() + + # everyone should have RandomFrames + assert random_frames.RandomFrames in cls._available_addons # available + assert schema_hash.has("addons.RandomFrames") # and in schema + # only AGIPD has the litpixelcounter (for now) + if cls == AgipdCorrection.AgipdCorrection: + assert litpixel_counter.LitPixelCounter in cls._available_addons + assert schema_hash.has("addons.LitPixelCounter") + else: + assert litpixel_counter.LitPixelCounter not in cls._available_addons + assert not schema_hash.has("addons.LitPixelCounter")