From cfdfaacfc87c723f6c42e8b3e7289879ed230b93 Mon Sep 17 00:00:00 2001 From: Shihab Suliman Date: Wed, 10 Jun 2026 15:45:48 +0000 Subject: [PATCH] refactor: use lower case plugin names --- src/fastcs_odin/frame_processor.py | 8 +++---- src/fastcs_odin/frame_receiver.py | 4 ++-- src/fastcs_odin/odin_data.py | 2 +- tests/test_controllers.py | 38 +++++++++++++++--------------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/fastcs_odin/frame_processor.py b/src/fastcs_odin/frame_processor.py index 50d1666..2ac4f9f 100644 --- a/src/fastcs_odin/frame_processor.py +++ b/src/fastcs_odin/frame_processor.py @@ -75,7 +75,7 @@ def __parameter_in_plugin( f"{self._api_prefix}", self._ios, ) - self.add_sub_controller(plugin.upper(), plugin_controller) + self.add_sub_controller(plugin, plugin_controller) await plugin_controller.initialise() @@ -100,7 +100,7 @@ class FrameProcessorAdapterController(OdinDataAdapterController): "fr_ready_cnxn", "fr_release_cnxn", ] - _subcontroller_label = "FP" + _subcontroller_label = "fp" _subcontroller_cls = FrameProcessorController def _collect_commands( @@ -187,14 +187,14 @@ def __dataset_parameter(param: OdinParameter): dataset_parameters, self.parameters = partition( self.parameters, __dataset_parameter ) - if dataset_parameters: + if dataset_parameters: dataset_controller = FrameProcessorDatasetController( self.connection, dataset_parameters, f"{self._api_prefix}", self._ios, ) - self.add_sub_controller("DS", dataset_controller) + self.add_sub_controller("ds", dataset_controller) await dataset_controller.initialise() def _construct_command(self, command_name, plugin_name): diff --git a/src/fastcs_odin/frame_receiver.py b/src/fastcs_odin/frame_receiver.py index 54bb792..4c5f4cd 100644 --- a/src/fastcs_odin/frame_receiver.py +++ b/src/fastcs_odin/frame_receiver.py @@ -21,7 +21,7 @@ def __decoder_parameter(parameter: OdinParameter): decoder_controller = FrameReceiverDecoderController( self.connection, decoder_parameters, f"{self._api_prefix}", self._ios ) - self.add_sub_controller("DECODER", decoder_controller) + self.add_sub_controller("decoder", decoder_controller) await decoder_controller.initialise() for parameter in self.parameters: @@ -36,7 +36,7 @@ def __decoder_parameter(parameter: OdinParameter): class FrameReceiverAdapterController(OdinDataAdapterController): - _subcontroller_label = "FR" + _subcontroller_label = "fr" _subcontroller_cls = FrameReceiverController _unique_config = [ "rank", diff --git a/src/fastcs_odin/odin_data.py b/src/fastcs_odin/odin_data.py index f811017..b740b76 100644 --- a/src/fastcs_odin/odin_data.py +++ b/src/fastcs_odin/odin_data.py @@ -21,7 +21,7 @@ class OdinDataAdapterController(ControllerVector): """Sub controller for the frame processor adapter in an odin control server.""" _unique_config: list[str] = [] - _subcontroller_label: str = "OD" + _subcontroller_label: str = "od" _subcontroller_cls: type[OdinSubController] = OdinSubController def __init__( diff --git a/tests/test_controllers.py b/tests/test_controllers.py index 8898cd6..9a10785 100644 --- a/tests/test_controllers.py +++ b/tests/test_controllers.py @@ -256,7 +256,7 @@ async def test_fp_create_plugin_sub_controllers(mocker: MockerFixture): controllers = fpc.sub_controllers match controllers: case { - "HDF": FrameProcessorPluginController( + "hdf": FrameProcessorPluginController( parameters=[ OdinParameter( uri=["status", "hdf", "frames_written"], @@ -268,10 +268,10 @@ async def test_fp_create_plugin_sub_controllers(mocker: MockerFixture): ] ) }: - sub_controllers = controllers["HDF"].sub_controllers - assert "DS" in sub_controllers - assert isinstance(sub_controllers["DS"], OdinSubController) - assert sub_controllers["DS"].parameters == [ + sub_controllers = controllers["hdf"].sub_controllers + assert "ds" in sub_controllers + assert isinstance(sub_controllers["ds"], OdinSubController) + assert sub_controllers["ds"].parameters == [ OdinParameter( uri=["status", "hdf", "dataset", "compressed_size", "compression"], _path=["compressed_size", "compression"], @@ -337,25 +337,25 @@ async def test_status_summary_attribute_io(): hdf1_controller = Controller() hdf2_controller = Controller() - controller.add_sub_controller("FP", fpa_controller) - fpa_controller.add_sub_controller("FP0", fp1_controller) - fpa_controller.add_sub_controller("FP1", fp2_controller) - fp1_controller.add_sub_controller("HDF", hdf1_controller) - fp2_controller.add_sub_controller("HDF", hdf2_controller) + controller.add_sub_controller("fp", fpa_controller) + fpa_controller.add_sub_controller("fp0", fp1_controller) + fpa_controller.add_sub_controller("fp1", fp2_controller) + fp1_controller.add_sub_controller("hdf", hdf1_controller) + fp2_controller.add_sub_controller("hdf", hdf2_controller) io = StatusSummaryAttributeIO() frames_written = AttrR( Int(), io_ref=StatusSummaryAttributeIORef( - ["FP", re.compile("FP*"), "HDF"], "frames_written", partial(sum, start=0) + ["fp", re.compile("fp*"), "hdf"], "frames_written", partial(sum, start=0) ), ) controller.frames_written = frames_written writing = AttrR( Bool(), io_ref=StatusSummaryAttributeIORef( - ["FP", re.compile("FP*"), ("HDF",)], "writing", any + ["fp", re.compile("fp*"), ("hdf",)], "writing", any ), ) controller.writing = writing @@ -380,14 +380,14 @@ async def test_status_summary_attribute_io(): @pytest.mark.asyncio -@pytest.mark.parametrize("mock_sub_controller", ("FP", ("FP",), re.compile("FP"))) +@pytest.mark.parametrize("mock_sub_controller", ("fp", ("fp",), re.compile("fp"))) async def test_status_summary_updater_raise_exception_if_controller_not_found( mock_sub_controller, mocker: MockerFixture ): controller = Controller() controller.writing = AttrR( - Bool(), StatusSummaryAttributeIORef(["OD", mock_sub_controller], "writing", any) + Bool(), StatusSummaryAttributeIORef(["od", mock_sub_controller], "writing", any) ) with pytest.raises(ValueError, match=r"Sub controller .* not found"): initialise_summary_attributes(controller) @@ -436,9 +436,9 @@ async def test_frame_reciever_controllers(): assert isinstance(fr_controller, FrameReceiverController) assert valid_non_decoder_parameter in fr_controller.parameters assert len(fr_controller.parameters) == 1 - assert "DECODER" in fr_controller.sub_controllers + assert "decoder" in fr_controller.sub_controllers - decoder_controller = fr_controller.sub_controllers["DECODER"] + decoder_controller = fr_controller.sub_controllers["decoder"] assert isinstance(decoder_controller, FrameReceiverDecoderController) assert valid_decoder_parameter in decoder_controller.parameters assert invalid_decoder_parameter not in decoder_controller.parameters @@ -457,7 +457,7 @@ async def test_frame_processor_start_and_stop_writing(mocker: MockerFixture): await fpc._create_plugin_sub_controllers(["hdf"]) # Mock the commands to check calls - hdf = fpc.sub_controllers["HDF"] + hdf = fpc.sub_controllers["hdf"] hdf.start_writing = mocker.AsyncMock() # type: ignore hdf.stop_writing = mocker.AsyncMock() # type: ignore @@ -493,10 +493,10 @@ async def test_status_summary_updater_raises_exception_if_attribute_not_found(): controller = Controller() sub_controller = Controller() - controller.add_sub_controller("OD", sub_controller) + controller.add_sub_controller("od", sub_controller) controller.writing = AttrR( - Bool(), StatusSummaryAttributeIORef(["OD"], "some_attribute", any) + Bool(), StatusSummaryAttributeIORef(["od"], "some_attribute", any) ) with pytest.raises(KeyError, match=r"Sub controller .* does not have attribute"): initialise_summary_attributes(controller)