From 8ff49ea0f18360b995f24d34ca1a5745255e1a5f Mon Sep 17 00:00:00 2001
From: Maciej Bak <maciej.bak@unibas.ch>
Date: Mon, 16 Aug 2021 21:02:30 +0200
Subject: [PATCH] hardcode cluster log relative path into the slurm profiles

---
 profiles/slurm-conda/config.yaml       |  1 +
 profiles/slurm-singularity/config.yaml |  1 +
 resources/config_schema.json           |  4 ++++
 workflow/Snakefile                     | 11 ++++++-----
 4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/profiles/slurm-conda/config.yaml b/profiles/slurm-conda/config.yaml
index 2fb0969..dcf0976 100644
--- a/profiles/slurm-conda/config.yaml
+++ b/profiles/slurm-conda/config.yaml
@@ -1,6 +1,7 @@
 jobscript: "../slurm-jobscript.sh"
 cluster: "../slurm-submit.py"
 cluster-status: "../slurm-status.py"
+config: "cluster_logs='logs/cluster'"
 snakefile: "../../workflow/Snakefile"
 cores: 256
 jobs: 256
diff --git a/profiles/slurm-singularity/config.yaml b/profiles/slurm-singularity/config.yaml
index 4fc0a6b..960bee6 100644
--- a/profiles/slurm-singularity/config.yaml
+++ b/profiles/slurm-singularity/config.yaml
@@ -1,6 +1,7 @@
 jobscript: "../slurm-jobscript.sh"
 cluster: "../slurm-submit.py"
 cluster-status: "../slurm-status.py"
+config: "cluster_logs='logs/cluster'"
 snakefile: "../../workflow/Snakefile"
 cores: 256
 jobs: 256
diff --git a/resources/config_schema.json b/resources/config_schema.json
index 1ad7846..299c43a 100644
--- a/resources/config_schema.json
+++ b/resources/config_schema.json
@@ -17,6 +17,10 @@
         "type": "string",
         "description": "Path to log directory."
       },
+      "cluster_logs": {
+        "type": "string",
+        "description": "Path to cluster log directory."
+      },
       "kallisto_indexes": {
         "type": "string",
         "description": "Path to kallisto indexes directory."
diff --git a/workflow/Snakefile b/workflow/Snakefile
index d5ac1ea..210c077 100644
--- a/workflow/Snakefile
+++ b/workflow/Snakefile
@@ -38,11 +38,12 @@ except KeyError:
     logger.warning(f"No rule config specified: using default values for all tools.")
 
 # Create dir for cluster logs, if applicable
-if cluster_config:
-    os.makedirs(
-        os.path.join(
-            os.getcwd(),
-            os.path.dirname(cluster_config['__default__']['out']),
+onstart:
+    if config["cluster_logs"]:
+        os.makedirs(
+            os.path.join(
+                os.getcwd(),
+                config["cluster_logs"],
         ),
         exist_ok=True)
 
-- 
GitLab