diff --git a/beat/core/execution/docker.py b/beat/core/execution/docker.py index 12e13f00808b53af7852c608f5e7e7006cd9a1f9..4a0839a878300980176b2247de020c0f30c115e9 100644 --- a/beat/core/execution/docker.py +++ b/beat/core/execution/docker.py @@ -35,21 +35,22 @@ Execution utilities import os import shutil +import logging import requests import simplejson import zmq import docker -import logging -logger = logging.getLogger(__name__) +from beat.backend.python.execution import MessageHandler from .. import stats -from .. import message_handler from .. import utils from .remote import RemoteExecutor +logger = logging.getLogger(__name__) + class DockerExecutor(RemoteExecutor): """DockerExecutor runs the code given an execution block information, externally @@ -309,8 +310,7 @@ class DockerExecutor(RemoteExecutor): port = utils.find_free_port_in_range(int(min_port), int(max_port)) address += ':{}'.format(port) - self.message_handler = message_handler.MessageHandler(address, - kill_callback=_kill) + self.message_handler = MessageHandler(address, kill_callback=_kill) #----- (If necessary) Instantiate the docker container that provide the databases diff --git a/beat/core/execution/local.py b/beat/core/execution/local.py index 2c6967ae3382f080e09dc9fc018db7012736a99a..9d89943bd8937f9b400966f5ac9fa2cedf55516f 100644 --- a/beat/core/execution/local.py +++ b/beat/core/execution/local.py @@ -52,11 +52,10 @@ from beat.backend.python.helpers import create_inputs_from_configuration from beat.backend.python.helpers import create_outputs_from_configuration from beat.backend.python.helpers import AccessMode -from beat.backend.python.executor import Executor -from beat.backend.python.message_handler import MessageHandler - -from beat.backend.python.loop_executor import Executor as LoopExecutor -from beat.backend.python.loop_executor import LoopMessageHandler +from beat.backend.python.execution import AlgorithmExecutor +from beat.backend.python.execution import MessageHandler +from beat.backend.python.execution import LoopExecutor +from beat.backend.python.execution import LoopMessageHandler class LocalExecutor(BaseExecutor): @@ -310,11 +309,11 @@ class LocalExecutor(BaseExecutor): self.loop_executor.process() - self.executor = Executor(self.executor_socket, - self.working_dir, - database_cache=self.databases, - cache_root=self.cache, - loop_socket=self.loop_socket) + self.executor = AlgorithmExecutor(self.executor_socket, + self.working_dir, + database_cache=self.databases, + cache_root=self.cache, + loop_socket=self.loop_socket) retval = self.executor.setup() if not retval: diff --git a/beat/core/execution/subprocess.py b/beat/core/execution/subprocess.py index 56e9485bd49b22ad51bde747d462f7ba25851d16..2419252f47c0f43a591567bab78e78baccc05578 100644 --- a/beat/core/execution/subprocess.py +++ b/beat/core/execution/subprocess.py @@ -38,22 +38,23 @@ from __future__ import absolute_import import os import shutil -import requests -import zmq +import logging import sys import subprocess as sp import tempfile +import requests +import zmq -import logging -logger = logging.getLogger(__name__) +from beat.backend.python.execution import MessageHandler from .. import stats -from .. import message_handler from .. import utils from .remote import RemoteExecutor +logger = logging.getLogger(__name__) + def _which(program): '''Pythonic version of the `which` command-line application''' @@ -287,8 +288,8 @@ class SubprocessExecutor(RemoteExecutor): def _kill(): algorithm_process.terminate() - self.message_handler = message_handler.MessageHandler(self.ip_address, - kill_callback=_kill) + self.message_handler = MessageHandler(self.ip_address, + kill_callback=_kill) #----- (If necessary) Instantiate the subprocess that provide the databases diff --git a/beat/core/message_handler.py b/beat/core/message_handler.py deleted file mode 100644 index de258a9c731e32893cc1d23e13f151cdd9928c52..0000000000000000000000000000000000000000 --- a/beat/core/message_handler.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/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/. # -# # -############################################################################### - -""" -=============== -message_handler -=============== - -Forward imported from :py:mod:`beat.backend.python.message_handler`: -:py:class:`beat.backend.python.message_handler.MessageHandler` -""" - - -from beat.backend.python.message_handler import MessageHandler diff --git a/doc/api.rst b/doc/api.rst index 7944bba5b20e0cd428ccd5c0e4507d29cc5c95ad..b0523c9c46c3ae2c64e3c8578b68e10443f790cd 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -67,8 +67,6 @@ This section includes information for using the Python API of ``beat.core``. .. automodule:: beat.core.loader -.. automodule:: beat.core.message_handler - .. automodule:: beat.core.outputs .. automodule:: beat.core.plotter