diff --git a/osa/configs/config.py b/osa/configs/config.py index 17a775dd..705110c5 100644 --- a/osa/configs/config.py +++ b/osa/configs/config.py @@ -1,10 +1,12 @@ """Open the lstosa configuration file.""" +import configparser import logging import sys -import configparser from pathlib import Path +from importlib_resources import files + from osa.configs import options from osa.utils.logging import myLogger @@ -22,9 +24,14 @@ def read_config(): config: ConfigParser Configuration file cfg """ + + DEFAULT_CFG = files("osa").joinpath("configs/sequencer.cfg") + for idx, arg in enumerate(sys.argv): if arg in ["-c", "--config"]: options.configfile = sys.argv[idx + 1] + else: + options.configfile = DEFAULT_CFG file = options.configfile diff --git a/cfg/sequencer.cfg b/osa/configs/sequencer.cfg similarity index 100% rename from cfg/sequencer.cfg rename to osa/configs/sequencer.cfg diff --git a/osa/tests/test_jobs.py b/osa/tests/test_jobs.py index 694d3621..2cf2cf9d 100644 --- a/osa/tests/test_jobs.py +++ b/osa/tests/test_jobs.py @@ -168,7 +168,7 @@ def test_create_job_template_scheduler( proc = subprocess.run([ 'datasequence', '--config', - '{Path.cwd()}/cfg/sequencer.cfg', + '{Path.cwd()}/osa/configs/sequencer.cfg', '--date=2020_01_17', '--prod-id=v0.1.0', '--drs4-pedestal-file={drs4_baseline_file}', @@ -211,7 +211,7 @@ def test_create_job_template_scheduler( proc = subprocess.run([ 'datasequence', '--config', - '{Path.cwd()}/cfg/sequencer.cfg', + '{Path.cwd()}/osa/configs/sequencer.cfg', '--date=2020_01_17', '--prod-id=v0.1.0', '--drs4-pedestal-file={drs4_baseline_file}', @@ -275,7 +275,7 @@ def test_create_job_template_local( proc = subprocess.run([ 'datasequence', '--config', - '{Path.cwd()}/cfg/sequencer.cfg', + '{Path.cwd()}/osa/configs/sequencer.cfg', '--date=2020_01_17', '--prod-id=v0.1.0', '--drs4-pedestal-file={drs4_baseline_file}', @@ -306,7 +306,7 @@ def test_create_job_template_local( proc = subprocess.run([ 'datasequence', '--config', - '{Path.cwd()}/cfg/sequencer.cfg', + '{Path.cwd()}/osa/configs/sequencer.cfg', '--date=2020_01_17', '--prod-id=v0.1.0', '--drs4-pedestal-file={drs4_baseline_file}', @@ -349,7 +349,7 @@ def test_create_job_scheduler_calibration(sequence_list): proc = subprocess.run([ 'calibration_pipeline', '--config', - '{Path.cwd()}/cfg/sequencer.cfg', + '{Path.cwd()}/osa/configs/sequencer.cfg', '--date=2020_01_17', '--drs4-pedestal-run=01804', '--pedcal-run=01805',