Setup worker run for files import tasks
Followup of https://gitlab.com/teklia/arkindex/tasks/-/merge_requests/339
The backend needs to create worker runs for the file import tasks (transkribus, s3 and file process modes) and expose their ID to the ponos tasks.
This snippet does that and allowed me to validate the tasks update
diff --git a/arkindex/process/models.py b/arkindex/process/models.py
index ca182da0..c7879dc1 100644
--- a/arkindex/process/models.py
+++ b/arkindex/process/models.py
@@ -464,9 +464,16 @@ class Process(IndexableModel):
if settings.INGEST_S3_REGION:
recipe['env']['INGEST_S3_REGION'] = settings.INGEST_S3_REGION
- if settings.IMPORTS_WORKER_VERSION and self.mode in (ProcessMode.Files, ProcessMode.S3):
+ if settings.IMPORTS_WORKER_VERSION and self.mode in (ProcessMode.Files, ProcessMode.S3, ProcessMode.Transkribus):
recipe['env']['WORKER_VERSION_ID'] = str(settings.IMPORTS_WORKER_VERSION)
+ worker_run = WorkerRun.objects.create(
+ process_id=self.id,
+ version_id=str(settings.IMPORTS_WORKER_VERSION),
+ parents=[],
+ )
+ recipe['env']['ARKINDEX_WORKER_RUN_ID'] = str(worker_run.id)
+
if self.corpus:
recipe['env']['ARKINDEX_CORPUS_ID'] = str(self.corpus.id)
We probably can remove the Worker version ID set as env variable too...