From c2d4bc95697fc8b013a2ad77e25829d5a39e5cc7 Mon Sep 17 00:00:00 2001
From: mlbonhomme <bonhomme@teklia.com>
Date: Wed, 23 Aug 2023 12:01:03 +0200
Subject: [PATCH] Remove WORKER_VERSION_ID env variable from processes

---
 arkindex/process/models.py                             | 2 --
 arkindex/process/tests/test_create_process.py          | 4 ----
 arkindex/process/tests/test_create_training_process.py | 3 ---
 arkindex/process/tests/test_processes.py               | 1 -
 arkindex/process/tests/test_workerruns.py              | 5 -----
 5 files changed, 15 deletions(-)

diff --git a/arkindex/process/models.py b/arkindex/process/models.py
index e0f1dd2eb7..187621b93f 100644
--- a/arkindex/process/models.py
+++ b/arkindex/process/models.py
@@ -586,7 +586,6 @@ class Process(IndexableModel):
             )
 
             env['ARKINDEX_WORKER_RUN_ID'] = str(worker_run.id)
-            env['WORKER_VERSION_ID'] = str(worker_version.id)
 
             # Build the training task, as there is no initial task
             training_task = self.build_task(
@@ -1257,7 +1256,6 @@ class WorkerRun(models.Model):
         )
 
         task_env["TASK_ELEMENTS"] = elements_path
-        task_env["WORKER_VERSION_ID"] = str(self.version.id)
         task_env["ARKINDEX_WORKER_RUN_ID"] = str(self.id)
         if chunk:
             task_env['ARKINDEX_TASK_CHUNK'] = str(chunk)
diff --git a/arkindex/process/tests/test_create_process.py b/arkindex/process/tests/test_create_process.py
index eb44a7d035..e4c6e6b68e 100644
--- a/arkindex/process/tests/test_create_process.py
+++ b/arkindex/process/tests/test_create_process.py
@@ -608,7 +608,6 @@ class TestCreateProcess(FixtureAPITestCase):
         self.assertEqual(list(reco_task.parents.all()), [init_task])
         self.assertEqual(reco_task.env, {
             'TASK_ELEMENTS': '/data/initialisation/elements.json',
-            'WORKER_VERSION_ID': str(self.version_1.id),
             'ARKINDEX_WORKER_RUN_ID': str(run_1.id),
             'ARKINDEX_PROCESS_ID': str(process_2.id),
             'ARKINDEX_CORPUS_ID': str(self.corpus.id),
@@ -622,7 +621,6 @@ class TestCreateProcess(FixtureAPITestCase):
         self.assertEqual(list(dla_task.parents.all()), [reco_task])
         self.assertEqual(dla_task.env, {
             'TASK_ELEMENTS': '/data/initialisation/elements.json',
-            'WORKER_VERSION_ID': str(self.version_2.id),
             'ARKINDEX_WORKER_RUN_ID': str(run_2.id),
             'ARKINDEX_PROCESS_ID': str(process_2.id),
             'ARKINDEX_CORPUS_ID': str(self.corpus.id),
@@ -702,7 +700,6 @@ class TestCreateProcess(FixtureAPITestCase):
             'TASK_ELEMENTS': '/data/initialisation/elements.json',
             'ARKINDEX_PROCESS_ID': str(process_2.id),
             'ARKINDEX_WORKER_RUN_ID': str(process_2.worker_runs.get().id),
-            'WORKER_VERSION_ID': str(self.version_1.id)
         })
         self.assertEqual(len(worker_task.parents.all()), 1)
         self.assertEqual(worker_task.parents.first(), init_task)
@@ -747,7 +744,6 @@ class TestCreateProcess(FixtureAPITestCase):
             'ARKINDEX_CORPUS_ID': str(self.corpus.id),
             'ARKINDEX_PROCESS_ID': str(process_2.id),
             'ARKINDEX_WORKER_RUN_ID': str(process_2.worker_runs.get().id),
-            'WORKER_VERSION_ID': str(self.version_3.id),
             'ARKINDEX_TASK_TOKEN': '67891'
         })
         self.assertEqual(worker_task.requires_gpu, True)
diff --git a/arkindex/process/tests/test_create_training_process.py b/arkindex/process/tests/test_create_training_process.py
index 991662a445..c22fd6cf59 100644
--- a/arkindex/process/tests/test_create_training_process.py
+++ b/arkindex/process/tests/test_create_training_process.py
@@ -312,7 +312,6 @@ class TestCreateTrainingProcess(FixtureTestCase):
             'ARKINDEX_PROCESS_ID': str(training_process.id),
             'ARKINDEX_TASK_TOKEN': '12345',
             'ARKINDEX_WORKER_RUN_ID': str(worker_run.id),
-            'WORKER_VERSION_ID': str(self.training_worker_version.id),
         })
         self.assertEqual(training_task.image, '1337')
         self.assertEqual(training_task.command, None)
@@ -397,7 +396,6 @@ class TestCreateTrainingProcess(FixtureTestCase):
             'ARKINDEX_PROCESS_ID',
             'ARKINDEX_TASK_TOKEN',
             'ARKINDEX_WORKER_RUN_ID',
-            'WORKER_VERSION_ID',
         ])
         self.assertEqual(task.requires_gpu, True)
         self.assertEqual(task.env['ARKINDEX_TASK_TOKEN'], task.token)
@@ -430,7 +428,6 @@ class TestCreateTrainingProcess(FixtureTestCase):
             'ARKINDEX_PROCESS_ID': str(training_process.id),
             'ARKINDEX_TASK_TOKEN': '12345',
             'ARKINDEX_WORKER_RUN_ID': str(worker_run.id),
-            'WORKER_VERSION_ID': str(self.training_worker_version.id),
         })
         self.assertEqual(task.slug, 'training')
         self.assertEqual(task.image, '1337')
diff --git a/arkindex/process/tests/test_processes.py b/arkindex/process/tests/test_processes.py
index 84fbc98fe0..004bdcda83 100644
--- a/arkindex/process/tests/test_processes.py
+++ b/arkindex/process/tests/test_processes.py
@@ -2561,7 +2561,6 @@ class TestProcesses(FixtureAPITestCase):
             'ARKINDEX_CORPUS_ID': str(self.corpus.id),
             'ARKINDEX_TASK_TOKEN': '78945',
             'ARKINDEX_WORKER_RUN_ID': str(run.id),
-            'WORKER_VERSION_ID': str(self.version_with_model.id),
             'TASK_ELEMENTS': '/data/initialisation/elements.json'
         })
         self.assertEqual(worker_task.image, run.version.docker_image_iid or run.version.docker_image_name)
diff --git a/arkindex/process/tests/test_workerruns.py b/arkindex/process/tests/test_workerruns.py
index 23547ea961..e629556a5c 100644
--- a/arkindex/process/tests/test_workerruns.py
+++ b/arkindex/process/tests/test_workerruns.py
@@ -2592,7 +2592,6 @@ class TestWorkerRuns(FixtureAPITestCase):
             'ARKINDEX_PROCESS_ID': '12345',
             'ARKINDEX_TASK_TOKEN': str(task.token),
             'TASK_ELEMENTS': '/data/import/elements.json',
-            'WORKER_VERSION_ID': str(self.version_1.id),
             'ARKINDEX_WORKER_RUN_ID': str(self.run_1.id),
         })
 
@@ -2611,7 +2610,6 @@ class TestWorkerRuns(FixtureAPITestCase):
             'ARKINDEX_TASK_TOKEN': str(task.token),
             'ARKINDEX_TASK_CHUNK': '4',
             'TASK_ELEMENTS': '/data/import/elements.json',
-            'WORKER_VERSION_ID': str(self.version_1.id),
             'ARKINDEX_WORKER_RUN_ID': str(self.run_1.id),
         })
 
@@ -2645,7 +2643,6 @@ class TestWorkerRuns(FixtureAPITestCase):
             'ARKINDEX_PROCESS_ID': '12345',
             'ARKINDEX_TASK_TOKEN': str(task.token),
             'TASK_ELEMENTS': '/data/import/elements.json',
-            'WORKER_VERSION_ID': str(version_2.id),
             'ARKINDEX_WORKER_RUN_ID': str(run_2.id),
         })
 
@@ -2680,7 +2677,6 @@ class TestWorkerRuns(FixtureAPITestCase):
             'ARKINDEX_TASK_TOKEN': str(task.token),
             'ARKINDEX_TASK_CHUNK': '4',
             'TASK_ELEMENTS': '/data/import/elements.json',
-            'WORKER_VERSION_ID': str(version_2.id),
             'ARKINDEX_WORKER_RUN_ID': str(run_2.id),
         })
 
@@ -2703,7 +2699,6 @@ class TestWorkerRuns(FixtureAPITestCase):
             'ARKINDEX_PROCESS_ID': '12345',
             'ARKINDEX_TASK_TOKEN': str(task.token),
             'TASK_ELEMENTS': '/data/import/elements.json',
-            'WORKER_VERSION_ID': str(self.version_1.id),
             'ARKINDEX_WORKER_RUN_ID': str(self.run_1.id),
         })
 
-- 
GitLab