Skip to content
Snippets Groups Projects
Commit 9642f24e authored by Philip ABBET's avatar Philip ABBET
Browse files

Refactoring: Integrate the LocalExecutor class from beat.cmdline

parent f0e07339
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
###############################################################################
# #
# Copyright (c) 2017 Idiap Research Institute, http://www.idiap.ch/ #
# Contact: beat.support@idiap.ch #
# #
# This file is part of the beat.core module of the BEAT platform. #
# #
# Commercial License Usage #
# Licensees holding valid commercial BEAT licenses may use this file in #
# accordance with the terms contained in a written agreement between you #
# and Idiap. For further information contact tto@idiap.ch #
# #
# Alternatively, this file may be used under the terms of the GNU Affero #
# Public License version 3 as published by the Free Software and appearing #
# in the file LICENSE.AGPL included in the packaging of this file. #
# The BEAT platform is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
# or FITNESS FOR A PARTICULAR PURPOSE. #
# #
# You should have received a copy of the GNU Affero Public License along #
# with the BEAT platform. If not, see http://www.gnu.org/licenses/. #
# #
###############################################################################
from .docker import DockerExecutor
from .local import LocalExecutor
...@@ -40,15 +40,15 @@ logger = logging.getLogger(__name__) ...@@ -40,15 +40,15 @@ logger = logging.getLogger(__name__)
import simplejson import simplejson
from . import schema from .. import schema
from . import database from .. import database
from . import algorithm from .. import algorithm
from . import inputs from .. import inputs
from . import outputs from .. import outputs
from . import data from .. import data
from . import stats from .. import stats
from . import agent from .. import agent
from . import dock from .. import dock
from beat.backend.python.helpers import convert_experiment_configuration_to_container from beat.backend.python.helpers import convert_experiment_configuration_to_container
from beat.backend.python.helpers import create_inputs_from_configuration from beat.backend.python.helpers import create_inputs_from_configuration
......
This diff is collapsed.
...@@ -47,6 +47,7 @@ import unittest ...@@ -47,6 +47,7 @@ import unittest
from ..experiment import Experiment from ..experiment import Experiment
from ..execution import DockerExecutor from ..execution import DockerExecutor
from ..execution import LocalExecutor
from ..hash import hashFileContents from ..hash import hashFileContents
from ..data import CachedDataSource from ..data import CachedDataSource
from ..dock import Host from ..dock import Host
...@@ -57,23 +58,6 @@ from .utils import cleanup ...@@ -57,23 +58,6 @@ from .utils import cleanup
class TestExecution(unittest.TestCase): class TestExecution(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.host = Host()
cls.host.setup(raise_on_errors=False)
@classmethod
def tearDownClass(cls):
cls.host.teardown()
cleanup()
def setUp(self):
super(TestExecution, self).setUp()
self.proxy_mode = True
def check_output(self, prefix, path): def check_output(self, prefix, path):
'''Checks if a given output exists, together with its indexes and checksums '''Checks if a given output exists, together with its indexes and checksums
''' '''
...@@ -130,9 +114,8 @@ class TestExecution(unittest.TestCase): ...@@ -130,9 +114,8 @@ class TestExecution(unittest.TestCase):
# can we execute it? # can we execute it?
results = [] results = []
for key, value in scheduled.items(): for key, value in scheduled.items():
executor = DockerExecutor(self.host, prefix, value['configuration'], tmp_prefix, executor = self.create_executor(prefix, value['configuration'], tmp_prefix,
dataformat_cache, database_cache, algorithm_cache, dataformat_cache, database_cache, algorithm_cache)
proxy_mode=self.proxy_mode)
assert executor.valid, '\n * %s' % '\n * '.join(executor.errors) assert executor.valid, '\n * %s' % '\n * '.join(executor.errors)
with executor: with executor:
...@@ -241,9 +224,6 @@ class TestExecution(unittest.TestCase): ...@@ -241,9 +224,6 @@ class TestExecution(unittest.TestCase):
def test_double_triangle_1(self): def test_double_triangle_1(self):
assert self.execute('user/user/double_triangle/1/double_triangle', [{'out_data': 42}]) is None assert self.execute('user/user/double_triangle/1/double_triangle', [{'out_data': 42}]) is None
def test_cxx_double_1(self):
assert self.execute('user/user/double/1/cxx_double', [{'out_data': 42}]) is None
def test_inputs_mix_1(self): def test_inputs_mix_1(self):
assert self.execute('user/user/inputs_mix/1/test', [{'sum': 12272, 'nb': 10}]) is None assert self.execute('user/user/inputs_mix/1/test', [{'sum': 12272, 'nb': 10}]) is None
...@@ -286,8 +266,54 @@ class TestExecution(unittest.TestCase): ...@@ -286,8 +266,54 @@ class TestExecution(unittest.TestCase):
class TestExecutionNoProxy(TestExecution): class TestDockerExecution(TestExecution):
@classmethod
def setUpClass(cls):
cls.host = Host()
cls.host.setup(raise_on_errors=False)
@classmethod
def tearDownClass(cls):
cls.host.teardown()
cleanup()
def setUp(self): def setUp(self):
super(TestExecutionNoProxy, self).setUp() super(TestDockerExecution, self).setUp()
self.proxy_mode = True
def create_executor(self, prefix, configuration, tmp_prefix, dataformat_cache,
database_cache, algorithm_cache):
return DockerExecutor(self.host, prefix, configuration, tmp_prefix,
dataformat_cache, database_cache, algorithm_cache,
proxy_mode=self.proxy_mode)
def test_cxx_double_1(self):
assert self.execute('user/user/double/1/cxx_double', [{'out_data': 42}]) is None
class TestDockerExecutionNoProxy(TestDockerExecution):
def setUp(self):
super(TestDockerExecutionNoProxy, self).setUp()
self.proxy_mode = False self.proxy_mode = False
class TestLocalExecution(TestExecution):
def create_executor(self, prefix, configuration, tmp_prefix, dataformat_cache,
database_cache, algorithm_cache):
return LocalExecutor(prefix, configuration, tmp_prefix,
dataformat_cache, database_cache, algorithm_cache)
# Don't run tests from the base class
del TestExecution
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment