From 4553fde719b3de179ec03b17260e046296c3bbe3 Mon Sep 17 00:00:00 2001
From: Christopher Rhodes <christopher.rhodes@embl.de>
Date: Wed, 18 Oct 2023 17:04:33 +0200
Subject: [PATCH] Create intermediary directories if they haven't been already

---
 extensions/chaeo/util.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/extensions/chaeo/util.py b/extensions/chaeo/util.py
index 9bed0644..60186ef5 100644
--- a/extensions/chaeo/util.py
+++ b/extensions/chaeo/util.py
@@ -89,8 +89,10 @@ def loop_workflow(files, where_output, workflow_func, params,
         # export intermediate data if flagged
         if write_intermediate_products:
             for k in result['interm'].keys():
+                path = Path(where_output) / k / (Path(ff).stem + '.tif')
+                path.parent.mkdir(parents=True, exist_ok=True)
                 write_accessor_data_to_file(
-                    Path(where_output) / k / (Path(ff).stem + '.tif'),
+                    path,
                     InMemoryDataAccessor(result['interm'][k])
                 )
 
-- 
GitLab