From 363107b343465d33af0a0714ccb01fc652c1059d Mon Sep 17 00:00:00 2001 From: Furkan Date: Thu, 7 Nov 2024 18:10:33 +0300 Subject: [PATCH] refactor: remove `parse_store_config` as we no longer use it --- src/daq/daq_job.py | 13 ------------- src/main.py | 9 --------- src/tests/test_main.py | 4 +--- 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/src/daq/daq_job.py b/src/daq/daq_job.py index 533f8f5..0f2d5b8 100644 --- a/src/daq/daq_job.py +++ b/src/daq/daq_job.py @@ -7,7 +7,6 @@ from daq.base import DAQJob, DAQJobThread from daq.models import DAQJobConfig -from daq.store.models import DAQJobStoreConfig from daq.types import DAQ_JOB_TYPE_TO_CLASS @@ -61,15 +60,3 @@ def start_daq_jobs(daq_jobs: list[DAQJob]) -> list[DAQJobThread]: threads.append(start_daq_job(daq_job)) return threads - - -def parse_store_config(config: dict) -> DAQJobStoreConfig: - from daq.store.types import DAQ_STORE_CONFIG_TYPE_TO_CLASS - - if "daq_job_store_type" not in config: - raise Exception("No daq_job_store_type specified in config") - - daq_job_store_type = config["daq_job_store_type"] - store_config_class = DAQ_STORE_CONFIG_TYPE_TO_CLASS[daq_job_store_type] - - return store_config_class(**config) diff --git a/src/main.py b/src/main.py index b3e8792..16c544c 100644 --- a/src/main.py +++ b/src/main.py @@ -8,14 +8,12 @@ from daq.base import DAQJob, DAQJobThread from daq.daq_job import ( load_daq_jobs, - parse_store_config, restart_daq_job, start_daq_jobs, ) from daq.jobs.handle_stats import DAQJobMessageStats, DAQJobStatsDict from daq.models import DAQJobMessage, DAQJobStats from daq.store.base import DAQJobStore -from daq.store.models import DAQJobMessageStore DAQ_SUPERVISOR_SLEEP_TIME = 0.2 DAQ_JOB_QUEUE_ACTION_TIMEOUT = 0.1 @@ -95,13 +93,6 @@ def send_messages_to_daq_jobs( daq_job_stats: DAQJobStatsDict, ): for message in daq_messages: - # TODO: Make this into a generalized interface - if isinstance(message, DAQJobMessageStore) and isinstance( - message.store_config, dict - ): - # Parse store config of DAQJobMessageStore - message.store_config = parse_store_config(message.store_config) - for daq_job_thread in daq_job_threads: daq_job = daq_job_thread.daq_job # Send if message is allowed for this DAQ Job diff --git a/src/tests/test_main.py b/src/tests/test_main.py index c33cc58..165e4f6 100644 --- a/src/tests/test_main.py +++ b/src/tests/test_main.py @@ -83,8 +83,7 @@ def test_get_messages_from_daq_jobs(self): self.assertEqual(result, [mock_message]) - @patch("main.parse_store_config") - def test_send_messages_to_daq_jobs(self, mock_parse_store_config): + def test_send_messages_to_daq_jobs(self): mock_thread = MagicMock() mock_thread.daq_job.allowed_message_in_types = [DAQJobMessageStore] mock_thread.daq_job.message_in = Queue() @@ -96,7 +95,6 @@ def test_send_messages_to_daq_jobs(self, mock_parse_store_config): send_messages_to_daq_jobs(daq_job_threads, [mock_message], {}) - mock_parse_store_config.assert_called_once_with({}) self.assertFalse(mock_thread.daq_job.message_in.empty()) self.assertEqual( mock_thread.daq_job.message_in.get(timeout=DAQ_JOB_QUEUE_ACTION_TIMEOUT),