From 0178a0c6b1f8b2e877c9bdd6556afd1a7010c391 Mon Sep 17 00:00:00 2001
From: Karim Ahmed <karim.ahmed@xfel.eu>
Date: Wed, 11 Mar 2020 19:08:46 +0100
Subject: [PATCH] change slurm out based on report name

---
 xfel_calibrate/calibrate.py | 9 ++++-----
 xfel_calibrate/finalize.py  | 8 ++++----
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/xfel_calibrate/calibrate.py b/xfel_calibrate/calibrate.py
index ceb838657..db8123a60 100755
--- a/xfel_calibrate/calibrate.py
+++ b/xfel_calibrate/calibrate.py
@@ -682,13 +682,12 @@ def concurrent_run(temp_path, nb, nbname, args, cparm=None, cval=None,
     return jobid
 
 
-def make_par_table(parms, temp_path, run_uuid):
+def make_par_table(parms, run_temp_path):
     """
     Create a table with input parameters if the notebook
 
     :param parms: parameters of the notebook
-    :param temp_path: path to temporary directory for job outputs
-    :param run_uuid: inset of folder name containing timestamp(fmt: YMD_HMS).
+    :param run_temp_path: path to temporary directory for running job outputs
     """
 
     # Add space in long strings without line breakers ` ,-/` to
@@ -744,7 +743,7 @@ def make_par_table(parms, temp_path, run_uuid):
                         \end{longtable}
                     ''')
 
-    f_name = "{}/slurm_tmp_{}/InputParameters.rst".format(temp_path, run_uuid)
+    f_name = "{}/InputParameters.rst".format(run_temp_path)
     with open(f_name, "w") as finfile:
         finfile.write(textwrap.dedent(tmpl.render(p=col_type, lines=l_parms)))
 
@@ -831,7 +830,7 @@ def run():
             cluster_profile = "slurm_prof_{}".format(run_uuid)
 
         # create a temporary output directory to work in
-        run_tmp_path = "{}/slurm_tmp_{}".format(temp_path, run_uuid)
+        run_tmp_path = "{}/slurm_out_{}_{}_{}".format(temp_path, detector, caltype, run_uuid)
         os.makedirs(run_tmp_path)
 
         # Write all input parameters to rst file to be included to final report
diff --git a/xfel_calibrate/finalize.py b/xfel_calibrate/finalize.py
index ff0a872b1..4a912bc61 100644
--- a/xfel_calibrate/finalize.py
+++ b/xfel_calibrate/finalize.py
@@ -281,11 +281,11 @@ def make_report(run_path, tmp_path, out_path, project, author, version,
     [rmtree(f'{dtmp}/') for dtmp in temp_dirs]
 
     # Moving temporary files to out-folder after successful execution
-    # This helps in keeping elements needed for reproducability.
+    # This helps in keeping elements needed for re-producibility.
     print(f"Moving temporary files to final location"
-          f": {out_path}/{os.path.basename(tmp_path)}")
-    move(tmp_path, f"{out_path}/{os.path.basename(tmp_path)}")
-
+          f": {out_path}/{os.path.basename(tmp_path)} with name: "
+          f"slurm_out_{report_name}")
+    move(tmp_path, f"{out_path}/slurm_out_{report_name}")
 
 
 def make_titlepage(sphinx_path, project, data_path, version):
-- 
GitLab