Skip to content

Commit 6512293

Browse files
committed
Add option to overwrite the existing Cat-B calibration files
1 parent 28e501a commit 6512293

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/osa/scripts/sequencer_catB_tailcuts.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
default=False,
5757
help="Overwrite the tailcuts config file if it already exists.",
5858
)
59+
parser.add_argument(
60+
"--overwrite-catB",
61+
action="store_true",
62+
default=False,
63+
help="Overwrite the Cat-B calibration files if they already exist.",
64+
)
5965
parser.add_argument(
6066
"tel_id",
6167
choices=["ST", "LST1", "LST2", "all"],
@@ -111,7 +117,7 @@ def launch_catB_calibration(run_id: int):
111117
before and it finished successfully, it creates a catB_{run}.closed file.
112118
"""
113119
job_id = get_catB_last_job_id(run_id)
114-
if job_id:
120+
if job_id and not options.overwrite_catB:
115121
job_status = get_sacct_output(run_sacct(job_id=job_id))["State"]
116122
if job_status.item() in ["RUNNING", "PENDING"]:
117123
log.debug(f"Job {job_id} (corresponding to run {run_id:05d}) is still running.")
@@ -129,8 +135,11 @@ def launch_catB_calibration(run_id: int):
129135

130136
else:
131137
if catB_calibration_file_exists(run_id):
132-
log.info(f"Cat-B calibration file already produced for run {run_id:05d}.")
133-
return
138+
if not options.overwrite_catB:
139+
log.info(f"Cat-B calibration file already produced for run {run_id:05d}.")
140+
return
141+
else:
142+
log.info(f"Cat-B calibration file already produced for run {run_id:05d}. Overwriting it.")
134143

135144
command = cfg.get("lstchain", "catB_calibration")
136145
if cfg.getboolean("lstchain", "use_lstcam_env_for_CatB_calib"):
@@ -162,6 +171,9 @@ def launch_catB_calibration(run_id: int):
162171
cmd.append(f"--dl1-dir={analysis_dir}")
163172
cmd.append(f"--lstchain-version={lstchain_version[1:]}")
164173

174+
if options.overwrite_catB:
175+
cmd.append("--yes")
176+
165177
if not options.simulate:
166178
job = sp.run(cmd, encoding="utf-8", capture_output=True, text=True, check=True)
167179
job_id = job.stdout.strip()
@@ -217,6 +229,7 @@ def main():
217229
options.tel_id = opts.tel_id
218230
options.simulate = opts.simulate
219231
options.overwrite_tailcuts = opts.overwrite_tailcuts
232+
options.overwrite_catB = opts.overwrite_catB
220233
options.date = opts.date
221234
options.date = set_default_date_if_needed()
222235
options.configfile = opts.config.resolve()

0 commit comments

Comments
 (0)