Skip to content

Commit ba5a18b

Browse files
authored
Merge pull request #381 from cta-observatory/datacheck-symlinks
Launch the creation of datacheck symlink with dependency on the merge datacheck jobs
2 parents e2039ad + ab818d8 commit ba5a18b

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

src/osa/paths.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def create_longterm_symlink(cherenkov_job_id: str=None):
409409
log.warning(f"Job {cherenkov_job_id} (lstchain_cherenkov_transparency) did not finish successfully.")
410410

411411

412-
def create_runwise_datacheck_symlinks():
412+
def create_runwise_datacheck_symlinks(parent_job_ids: List[str]):
413413
"""Create symlinks of the run-wise datacheck files in the "datacheck" directory."""
414414
nightdir = utils.date_to_dir(options.date)
415415
dl1_dir = Path(cfg.get("LST1", "DL1_DIR")) / nightdir / options.prod_id
@@ -421,11 +421,24 @@ def create_runwise_datacheck_symlinks():
421421
"tailcut*/datacheck/datacheck_dl1_LST-1.Run?????.h5",
422422
]
423423

424+
commands = []
424425
for pattern in patterns:
425426
for input_file in dl1_dir.rglob(pattern):
426427
output_file = output_dir / input_file.name
427428
if not output_file.is_symlink():
428-
output_file.symlink_to(input_file.resolve())
429+
commands.append(f'ln -s "$(realpath {input_file})" {output_file}')
430+
431+
if commands:
432+
full_cmd = "\n".join(commands)
433+
434+
sbatch_cmd = [
435+
"sbatch",
436+
f"--dependency=afterok:{','.join(parent_job_ids)}",
437+
"--wrap",
438+
full_cmd,
439+
]
440+
441+
subprocess.run(sbatch_cmd, check=True)
429442

430443

431444
def create_muons_symlinks():
@@ -443,12 +456,12 @@ def create_muons_symlinks():
443456
output_file.symlink_to(input_file.resolve())
444457

445458

446-
def create_datacheck_symlinks():
459+
def create_datacheck_symlinks(parent_job_ids: List[str]):
447460
"""Create symlinks of the run-wise datacheck files, and of the muon
448461
files in the "datacheck" directory."""
449462

450463
log.info("Creating symlinks of the datacheck and muon files in the common directory.")
451-
create_runwise_datacheck_symlinks()
464+
create_runwise_datacheck_symlinks(parent_job_ids)
452465
create_muons_symlinks()
453466

454467

src/osa/scripts/closer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def post_process(seq_tuple):
185185
# the longterm DL1 datacheck file with the cherenkov_transparency script.
186186
if cfg.getboolean("lstchain", "merge_dl1_datacheck"):
187187
list_job_id = merge_dl1_datacheck(seq_list)
188-
create_datacheck_symlinks()
188+
create_datacheck_symlinks(list_job_id)
189189
longterm_job_id = daily_datacheck(daily_longterm_cmd(list_job_id))
190190
cherenkov_job_id = cherenkov_transparency(cherenkov_transparency_cmd(longterm_job_id))
191191
if cfg.getboolean("lstchain", "create_longterm_symlink"):

0 commit comments

Comments
 (0)