Skip to content

Commit

Permalink
Merge pull request #317 from cta-observatory/slurm-account
Browse files Browse the repository at this point in the history
Use the SLURM account specified in the cfg also for the gainsel and autocloser jobs
  • Loading branch information
morcuended authored Nov 11, 2024
2 parents 86eaca1 + 5301397 commit ec87414
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/osa/scripts/closer.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ def merge_dl1_datacheck(seq_list) -> List[str]:

muons_dir = destination_dir("MUON", create_dir=False)
datacheck_dir = destination_dir("DATACHECK", create_dir=False)
slurm_account = cfg.get("SLURM", "ACCOUNT")

list_job_id = []

Expand All @@ -344,6 +345,7 @@ def merge_dl1_datacheck(seq_list) -> List[str]:
cmd = [
"sbatch",
"--parsable",
f"--account={slurm_account}",
"-D",
options.directory,
"-o",
Expand Down Expand Up @@ -386,13 +388,15 @@ def extract_provenance(seq_list):
log.info("Extract provenance run wise")

nightdir = date_to_dir(options.date)
slurm_account = cfg.get("SLURM", "ACCOUNT")

for sequence in seq_list:
if sequence.type == "DATA":
drs4_pedestal_run_id = str(sequence.drs4_run)
pedcal_run_id = str(sequence.pedcal_run)
cmd = [
"sbatch",
f"--account={slurm_account}",
"-D",
options.directory,
"-o",
Expand Down Expand Up @@ -433,13 +437,15 @@ def merge_files(sequence_list, data_level="DL2"):

data_dir = destination_dir(data_level, create_dir=False)
pattern, prefix = get_pattern(data_level)
slurm_account = cfg.get("SLURM", "ACCOUNT")

for sequence in sequence_list:
if sequence.type == "DATA":
merged_file = Path(data_dir) / f"{prefix}_LST-1.Run{sequence.run:05d}.h5"

cmd = [
"sbatch",
f"--account={slurm_account}",
"-D",
options.directory,
"-o",
Expand Down Expand Up @@ -467,12 +473,14 @@ def merge_muon_files(sequence_list):

data_dir = destination_dir("MUON", create_dir=False)
pattern, prefix = get_pattern("MUON")
slurm_account = cfg.get("SLURM", "ACCOUNT")

for sequence in sequence_list:
merged_file = Path(data_dir) / f"muons_LST-1.Run{sequence.run:05d}.fits"

cmd = [
"sbatch",
f"--account={slurm_account}",
"-D",
options.directory,
"-o",
Expand All @@ -499,10 +507,12 @@ def daily_longterm_cmd(parent_job_ids: List[str]) -> List[str]:
muons_dir = destination_dir("MUON", create_dir=False)
longterm_dir = Path(cfg.get("LST1", "LONGTERM_DIR")) / options.prod_id / nightdir
longterm_output_file = longterm_dir / f"DL1_datacheck_{nightdir}.h5"
slurm_account = cfg.get("SLURM", "ACCOUNT")

return [
"sbatch",
"--parsable",
f"--account={slurm_account}",
"-D",
options.directory,
"-o",
Expand Down Expand Up @@ -541,10 +551,12 @@ def cherenkov_transparency_cmd(longterm_job_id: str) -> List[str]:
datacheck_dir = destination_dir("DATACHECK", create_dir=False)
longterm_dir = Path(cfg.get("LST1", "LONGTERM_DIR")) / options.prod_id / nightdir
longterm_datacheck_file = longterm_dir / f"DL1_datacheck_{nightdir}.h5"
slurm_account = cfg.get("SLURM", "ACCOUNT")

return [
"sbatch",
"--parsable",
f"--account={slurm_account}",
"-D",
options.directory,
"-o",
Expand Down
2 changes: 2 additions & 0 deletions src/osa/scripts/gain_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def get_sbatch_script(
):
"""Build the sbatch job pilot script for running the gain selection."""
mem_per_job = cfg.get("SLURM", "MEMSIZE_GAINSEL")
slurm_account = cfg.get("SLURM", "ACCOUNT")
sbatch_script = dedent(
f"""\
#!/bin/bash
Expand All @@ -123,6 +124,7 @@ def get_sbatch_script(
#SBATCH --job-name "gain_selection_{run_id:05d}"
#SBATCH --partition=short,long
#SBATCH --mem={mem_per_job}
#SBATCH --account={slurm_account}
"""
)

Expand Down
3 changes: 3 additions & 0 deletions src/osa/scripts/tests/test_osa_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import yaml

from osa.configs import options
from osa.configs.config import cfg
from osa.scripts.closer import is_sequencer_successful, is_finished_check

ALL_SCRIPTS = [
Expand Down Expand Up @@ -326,10 +327,12 @@ def test_daily_longterm_cmd():

job_ids = ["12345", "54321"]
cmd = daily_longterm_cmd(parent_job_ids=job_ids)
slurm_account = cfg.get("SLURM", "ACCOUNT")

expected_cmd = [
"sbatch",
"--parsable",
f"--account={slurm_account}",
"-D",
options.directory,
"-o",
Expand Down

0 comments on commit ec87414

Please sign in to comment.