Skip to content

Commit

Permalink
refactor: update daq config sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
furkan-bilgin committed Oct 7, 2024
1 parent 135ecc9 commit 2f582af
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/daq/daq_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
from daq.caen.n1081b import DAQJobN1081B
from daq.models import DAQJob, DAQJobConfig

DAQ_JOB_TYPE_TO_CLASS = {
DAQ_JOB_TYPE_TO_CLASS: dict[str, type[DAQJob]] = {
"n1081b": DAQJobN1081B,
}


def build_daq_job(toml_config: dict) -> DAQJob:
generic_daq_job_config = DAQJobConfig.from_dict(toml_config)

# Get DAQ and DAQ config clasess based on daq_job_type
daq_job_class = DAQ_JOB_TYPE_TO_CLASS[generic_daq_job_config.daq_job_type]
if not issubclass(daq_job_class, DAQJob):
if generic_daq_job_config.daq_job_type not in DAQ_JOB_TYPE_TO_CLASS:
raise Exception(f"Invalid DAQ job type: {generic_daq_job_config.daq_job_type}")

# Get DAQ and DAQ config clasess based on daq_job_type
daq_job_class = DAQ_JOB_TYPE_TO_CLASS[generic_daq_job_config.daq_job_type]
daq_job_config_class = daq_job_class.config_type

# Load the config in
Expand Down

0 comments on commit 2f582af

Please sign in to comment.