From 13fb5af4232c2f224fe19dc949e5d526538872b5 Mon Sep 17 00:00:00 2001
From: Valentin Rigal <rigal@teklia.com>
Date: Tue, 30 Jul 2024 14:36:35 +0200
Subject: [PATCH] Download extra files before running task's container

---
 arkindex/ponos/tasks.py | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/arkindex/ponos/tasks.py b/arkindex/ponos/tasks.py
index e7b57f5a55..c8ea34aa2b 100644
--- a/arkindex/ponos/tasks.py
+++ b/arkindex/ponos/tasks.py
@@ -148,7 +148,20 @@ def run_docker_task(client, task, temp_dir):
             assert str(folder.resolve()) in str(path.resolve()), "Invalid artifact path: {artifact.path}."
             artifact.download_to(str(path))
 
-    # 3. Do run the container asynchronously
+    # 3. Download extra_files
+    if task.extra_files:
+        logger.info(f"Downloading extra_files for task {task!s}")
+        try:
+            download_extra_files(task, temp_dir)
+        except Exception as e:
+            logger.warning(
+                f"Failed downloading extra_files for task {task!s}: {e!s}"
+            )
+            task.state = State.Error
+            task.save()
+            return
+
+    # 4. Do run the container asynchronously
     logger.debug("Running container")
     kwargs = {
         "environment": {
@@ -179,19 +192,6 @@ def run_docker_task(client, task, temp_dir):
     task.state = State.Running
     task.save()
 
-    # 4. Download extra_files
-    if task.extra_files:
-        logger.info(f"Downloading extra_files for task {task!s}")
-        try:
-            download_extra_files(task, temp_dir)
-        except Exception as e:
-            logger.warning(
-                f"Failed downloading extra_files for task {task!s}: {e!s}"
-            )
-            task.state = State.Error
-            task.save()
-            return
-
     # 5. Read logs
     logger.debug("Reading logs from the docker container")
     previous_logs = b""
-- 
GitLab