From 3f9c2237767201919d7b0e4db82b7e20b5d85f92 Mon Sep 17 00:00:00 2001
From: schroeder5 <s.schroeder@fz-juelich.de>
Date: Tue, 28 May 2024 05:54:38 +0000
Subject: [PATCH] download results of ML downscaling

---
 src/pages/dashboard.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/pages/dashboard.py b/src/pages/dashboard.py
index ff317a2..f860735 100644
--- a/src/pages/dashboard.py
+++ b/src/pages/dashboard.py
@@ -1336,8 +1336,17 @@ def ml_downscaling_output_download(download_button, job_dict, plot_dict):
             job_description = {'Executable': f"/p/project/deepacf/intelliaq/schroeder5/downscaling_maelstrom/HPC_batch_scripts/inference_destine_test_{variable}.sh",
                                'Arguments': [ f"{jobnr.upper()}/CTM/", year, month, day ] }
             job = client.new_job(job_description)
-        else:
-            os.symlink(downscaling_filename, infile)
+            # wait for the job to finish:
+            while str(job.status) != 'JobStatus.SUCCESSFUL':
+                sleep(3)
+            # transfer the result file
+            base_directory = f"{UNICORE_USER}/{jobnr.upper()}/CTM/{year}{month}/{day}"
+            transport = uc_client.Transport(credentials)
+            scratch = uc_client.Storage(transport, f"{base_url}/storages/SCRATCH")
+            dfile = scratch.stat(f"{base_directory}/downscaling_{variable}_{year}{month}{day}00.nc")
+            dfile.download(downscaling_filename)
+
+        os.symlink(downscaling_filename, infile)
 
     return dcc.send_file(
         infile
-- 
GitLab