Skip to content

Commit

Permalink
refactor: remove parse_store_config as we no longer use it
Browse files Browse the repository at this point in the history
  • Loading branch information
furkan-bilgin committed Nov 7, 2024
1 parent fb03383 commit 363107b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 25 deletions.
13 changes: 0 additions & 13 deletions src/daq/daq_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)
9 changes: 0 additions & 9 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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),
Expand Down

0 comments on commit 363107b

Please sign in to comment.