From 445e4550fe28c8cb76379e79ab0b393830283910 Mon Sep 17 00:00:00 2001 From: marialainez Date: Tue, 17 Oct 2023 12:54:17 +0000 Subject: [PATCH 1/3] Add start and end time of jobs running as input arguments for gain selection --- src/osa/scripts/gain_selection.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/osa/scripts/gain_selection.py b/src/osa/scripts/gain_selection.py index 3be407f6..39ae7518 100644 --- a/src/osa/scripts/gain_selection.py +++ b/src/osa/scripts/gain_selection.py @@ -41,7 +41,7 @@ def get_sbatch_script( ) -def apply_gain_selection(date: str, output_basedir: Path = None): +def apply_gain_selection(date: str, output_basedir: Path = None, start: int, end: int): """ Submit the jobs to apply the gain selection to the data for a given date on a subrun-by-subrun basis. @@ -64,7 +64,7 @@ def apply_gain_selection(date: str, output_basedir: Path = None): check_job_status_and_wait(max_jobs=1500) # Avoid running jobs while it is still night time - wait_for_daytime(start=12, end=18) + wait_for_daytime(start, end) run_id = run["run_id"] ref_time = run["dragon_reference_time"] @@ -121,7 +121,7 @@ def apply_gain_selection(date: str, output_basedir: Path = None): for run in calib_runs: # Avoid copying files while it is still night time - wait_for_daytime(start=12, end=18) + wait_for_daytime(start, end) run_id = run["run_id"] r0_files = r0_dir.glob(f"LST-1.?.Run{run_id:05d}.????.fits.fz") @@ -206,7 +206,15 @@ def check_failed_jobs(date: str, output_basedir: Path = None): @click.option("--check", is_flag=True, default=False, help="Check for failed jobs.") @click.argument("dates-file", type=click.Path(exists=True, path_type=Path)) @click.argument("output-basedir", type=click.Path(path_type=Path)) -def main(dates_file: Path = None, output_basedir: Path = None, check: bool = False): +@click.option("-s", "--start-time", type=int, default=10) +@click.option("-e", "--end-time", type=int, default=18) +def main( + dates_file: Path = None, + output_basedir: Path = None, + check: bool = False, + start_time: int = 10, + end_time: int = 18 +): """ Loop over the dates listed in the input file and launch the gain selection script for each of them. The input file should list the dates in the format @@ -221,7 +229,7 @@ def main(dates_file: Path = None, output_basedir: Path = None, check: bool = Fal check_failed_jobs(date, output_basedir) else: for date in list_of_dates: - apply_gain_selection(date, output_basedir) + apply_gain_selection(date, output_basedir, start_time, end_time) log.info("Done! No more dates to process.") From 9d134d25a7c0489d66f32a9751b24e3fc37d75f0 Mon Sep 17 00:00:00 2001 From: marialainez Date: Tue, 17 Oct 2023 13:12:21 +0000 Subject: [PATCH 2/3] put optional argument as the last one --- src/osa/scripts/gain_selection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osa/scripts/gain_selection.py b/src/osa/scripts/gain_selection.py index 39ae7518..6aa9c9b6 100644 --- a/src/osa/scripts/gain_selection.py +++ b/src/osa/scripts/gain_selection.py @@ -41,7 +41,7 @@ def get_sbatch_script( ) -def apply_gain_selection(date: str, output_basedir: Path = None, start: int, end: int): +def apply_gain_selection(date: str, start: int, end: int, output_basedir: Path = None): """ Submit the jobs to apply the gain selection to the data for a given date on a subrun-by-subrun basis. From 0b762d0863a44f7d3145c75c29b8e139dbdade2d Mon Sep 17 00:00:00 2001 From: marialainez Date: Tue, 17 Oct 2023 13:14:20 +0000 Subject: [PATCH 3/3] change order of arguments when calling function --- src/osa/scripts/gain_selection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osa/scripts/gain_selection.py b/src/osa/scripts/gain_selection.py index 6aa9c9b6..214623e6 100644 --- a/src/osa/scripts/gain_selection.py +++ b/src/osa/scripts/gain_selection.py @@ -229,7 +229,7 @@ def main( check_failed_jobs(date, output_basedir) else: for date in list_of_dates: - apply_gain_selection(date, output_basedir, start_time, end_time) + apply_gain_selection(date, start_time, end_time, output_basedir) log.info("Done! No more dates to process.")