From a7e450aaef6049364eebcd8d175d71a9457dbeda Mon Sep 17 00:00:00 2001
From: Timo Millenaar <tmillenaar@gmail.com>
Date: Tue, 15 Oct 2024 16:04:39 +0200
Subject: [PATCH] Properly specify pipeline outputs in aggregate_and_plot.cwl

---
 aggregate_and_plot.cwl | 14 +++++++++++++-
 aggregate_and_plot.py  |  8 ++++----
 aggregate_and_plot.sh  |  2 +-
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/aggregate_and_plot.cwl b/aggregate_and_plot.cwl
index f55e055..7fc1214 100644
--- a/aggregate_and_plot.cwl
+++ b/aggregate_and_plot.cwl
@@ -15,4 +15,16 @@ inputs:
     inputBinding:
       position: 1  # The first argument after the script will be the workdir
 
-outputs: []
+outputs:
+- id: plots
+  type: File[]
+  outputBinding:
+    glob: "*.png"
+- id: outputs
+  type: File
+  outputBinding:
+    glob: "outputs.txt"
+- id: inspect
+  type: File
+  outputBinding:
+    glob: "inspect.h5"
diff --git a/aggregate_and_plot.py b/aggregate_and_plot.py
index 8eb79cb..8588656 100644
--- a/aggregate_and_plot.py
+++ b/aggregate_and_plot.py
@@ -31,14 +31,14 @@ def main():
                 logging.info(f"Could not find the following input file: {line}")
         logging.info(f"Found {len(h5_paths)} h5 files")
 
-    h5_output_path = workdir / "inspect.h5"
+    h5_output_path = "inspect.h5"
     join_inspect_ds(h5_paths, h5_output_path)
     plot_paths = plot_inspect_ds(h5_output_path, workdir, min_elevation=15)
 
-    with open(workdir / "outputs.txt", "w") as file:
-        file.write(str(h5_output_path.absolute()) + "\n")
+    with open("outputs.txt", "w") as file:
+        file.write(str(h5_output_path) + "\n")
         for file_path in plot_paths:
-            path = Path(file_path).absolute()
+            path = Path(file_path)
             file.write(str(path) + "\n")
 
 if __name__ == "__main__":
diff --git a/aggregate_and_plot.sh b/aggregate_and_plot.sh
index 63ae9d4..36fcbf4 100644
--- a/aggregate_and_plot.sh
+++ b/aggregate_and_plot.sh
@@ -14,4 +14,4 @@ else
 fi
 export SINGULARITY_BIND="/project:/project"
 export TOIL_SLURM_ARGS=""
-toil-cwl-runner "${SCRIPT_DIR}/imaging_compress_pipeline.git/aggregate_and_plot.cwl" --workdir $SCRIPT_DIR --logDebug --singularity --batchSystem slurm --batchLogsDir ./logs --jobStore ./job_store
+toil-cwl-runner "${SCRIPT_DIR}/imaging_compress_pipeline.git/aggregate_and_plot.cwl" --workdir $SCRIPT_DIR --outdir $SCRIPT_DIR --logDebug --singularity --batchSystem slurm --batchLogsDir ./logs --jobStore ./job_store --clean always
-- 
GitLab