From c3035a58c482748f001e2ea857ab75d890173f18 Mon Sep 17 00:00:00 2001
From: Philip ABBET <philip.abbet@idiap.ch>
Date: Mon, 21 Aug 2017 14:34:40 +0200
Subject: [PATCH] Optimization: cache the discovery of docker images

---
 beat/web/backend/models.py  | 4 ++--
 beat/web/scripts/process.py | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
 mode change 100644 => 100755 beat/web/scripts/process.py

diff --git a/beat/web/backend/models.py b/beat/web/backend/models.py
index d7a62713d..2ac9cf1f3 100755
--- a/beat/web/backend/models.py
+++ b/beat/web/backend/models.py
@@ -1365,7 +1365,7 @@ class JobSplit(models.Model):
         self.end(result)
 
 
-    def process(self, cache=settings.CACHE_ROOT):
+    def process(self, cache=settings.CACHE_ROOT, docker_images_cache=None):
         '''Process assigned job splits using beat.core
 
         This task executes the user algorithm on a subprocess. It also serves
@@ -1419,7 +1419,7 @@ class JobSplit(models.Model):
         try:
 
             if JobSplit.host is None:
-                JobSplit.host = Host()
+                JobSplit.host = Host(images_cache=docker_images_cache)
                 JobSplit.host.setup(raise_on_errors=not(getattr(settings, 'TEST_CONFIGURATION', False)))
 
             self.executor = beat.core.execution.Executor(settings.PREFIX, config,
diff --git a/beat/web/scripts/process.py b/beat/web/scripts/process.py
old mode 100644
new mode 100755
index 8c44eba51..326a12b16
--- a/beat/web/scripts/process.py
+++ b/beat/web/scripts/process.py
@@ -115,4 +115,4 @@ def main(user_input=None):
     signal.signal(signal.SIGTERM, handler)
     signal.signal(signal.SIGINT, handler)
 
-    split.process()
+    split.process(docker_images_cache='/tmp/beat_docker_images.json')
-- 
GitLab