From d1aaa472a588e65274ad9f3789530ef065a52949 Mon Sep 17 00:00:00 2001 From: Samuel Gaist <samuel.gaist@idiap.ch> Date: Tue, 27 Nov 2018 13:42:57 +0100 Subject: [PATCH] [core] Removed almost unused message_handler file and update imports where needed --- beat/core/execution/docker.py | 10 ++++---- beat/core/execution/local.py | 19 ++++++++-------- beat/core/execution/subprocess.py | 15 ++++++------ beat/core/message_handler.py | 38 ------------------------------- doc/api.rst | 2 -- 5 files changed, 22 insertions(+), 62 deletions(-) delete mode 100644 beat/core/message_handler.py diff --git a/beat/core/execution/docker.py b/beat/core/execution/docker.py index 12e13f00..4a0839a8 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 2c6967ae..9d89943b 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 56e9485b..2419252f 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 de258a9c..00000000 --- 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 7944bba5..b0523c9c 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 -- GitLab