From af3d6310c86a0caf59dea5933ee2f89e27f86ba7 Mon Sep 17 00:00:00 2001 From: Nadine Wieters Date: Thu, 14 Dec 2023 16:09:11 +0100 Subject: [PATCH] Added jobid to name of logfiles. --- src/esm_runscripts/compute.py | 4 +++- src/esm_runscripts/logfiles.py | 5 +++++ src/esm_runscripts/prepexp.py | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/esm_runscripts/compute.py b/src/esm_runscripts/compute.py index 596db3f6b..ebfffe3b4 100644 --- a/src/esm_runscripts/compute.py +++ b/src/esm_runscripts/compute.py @@ -282,11 +282,13 @@ def initialize_experiment_logfile(config): if "trace_sink" in dir(logger): experiment_dir = config["general"]["experiment_dir"] expid = config["general"]["expid"] + jobid = config["general"].get("jobid", None) + jobid = f"_{jobid}" if jobid else "" it_coupled_model_name = config["general"]["iterative_coupled_model"] datestamp = config["general"]["run_datestamp"] logfile_path = ( f"{experiment_dir}/log/" - f"{expid}_{it_coupled_model_name}esm_runscripts_{datestamp}.log" + f"{expid}_{it_coupled_model_name}esm_runscripts_{datestamp}{jobid}.log" ) logger.trace_sink.def_path(logfile_path) diff --git a/src/esm_runscripts/logfiles.py b/src/esm_runscripts/logfiles.py index 102c0d233..080e0fa36 100644 --- a/src/esm_runscripts/logfiles.py +++ b/src/esm_runscripts/logfiles.py @@ -63,9 +63,13 @@ def finalize_logfiles(config, org_jobtype): def set_logfile_name(config, jobtype=None): + jobid = config["general"].get("jobid", None) + jobid = f"_{jobid}" if jobid else "" + if not jobtype: jobtype = config["general"]["jobtype"] + filejobtype = jobtype # if "observe" in filejobtype: # filejobtype = filejobtype.replace("observe_", "") @@ -92,6 +96,7 @@ def set_logfile_name(config, jobtype=None): + filejobtype + "_" + config["general"]["run_datestamp"] + + jobid + ".log" ) diff --git a/src/esm_runscripts/prepexp.py b/src/esm_runscripts/prepexp.py index 8ac0359cd..9f1c51cba 100644 --- a/src/esm_runscripts/prepexp.py +++ b/src/esm_runscripts/prepexp.py @@ -247,6 +247,10 @@ def initialize_experiment_logfile(config): experiment_dir = config["general"]["experiment_dir"] expid = config["general"]["expid"] + jobtype = config["general"].get("jobtype", None) + jobtype = f"_{jobtype}" if jobtype else "" + jobid = config["general"].get("jobid", None) + jobid = f"_{jobid}" if jobid else "" it_coupled_model = config["general"]["iterative_coupled_model"] datestamp = config["general"]["run_datestamp"] @@ -272,7 +276,7 @@ def initialize_experiment_logfile(config): if "trace_sink" in dir(logger): logfile_path = ( f"{experiment_dir}/log/" - f"{expid}_{it_coupled_model}esm_runscripts_{datestamp}.log" + f"{expid}_{it_coupled_model}esm_runscripts{jobtype}_{datestamp}{jobid}.log" ) logger.trace_sink.def_path(logfile_path)