Exemple #1
0
import sys
import importlib
import time
import json

from starlette.responses import Response
from utils import configureLogger

logger = configureLogger("model")


def error_code(e):
    if isinstance(e, AssertionError): return 400
    if isinstance(e, ValueError): return 422
    return 500

def error_response(e):
    code = error_code(e)
    json_body = { "error": { "code": code, "message": str(e) }}
    return Response(json.dumps(json_body), status_code=code, media_type="application/json")

class Model:
    def __init__(self, name, version, response_content_type=None):
        self.name = name
        self.version = version
        self.response_content_type = response_content_type

        self.fns = importlib.import_module(f"models.{name}.inference")
        logger.debug(f"imported model module")

        self.model = self._load_model()
Exemple #2
0
      pass

    def check_computations(self, driver):
        if self.runnig_task is None:
            return False

        if not self.runnig_task.is_finished():
            return False
        logger.info("Task %s is finished. Trying to report to the master" % self.runnig_task.task['id'])
        message = messages.create_message(messages.EMT_TASKFINISHED, self.runnig_task.task_repr())
        driver.sendFrameworkMessage(message)

        self.runnig_task = None
        return True

if __name__ == "__main__":

    if len(sys.argv) > 1:
        time_label = sys.argv[1]
    else:
        time_label = utils.get_time_label()

    utils.configureLogger(time_label = time_label, is_executor=True)
    logger = logging.getLogger(utils.DEFAULT_LOGGER_NAME)

    logger.info("Starting Launching Executor (LE)")
    driver = MesosExecutorDriver(TestExecutor())
    exit_code = 0 if driver.run() == mesos_pb2.DRIVER_STOPPED else 1
    logger.info("Executor is finished")
    sys.exit(exit_code)
Exemple #3
0
        return not_calculated_bsm, not_calculated_swan


def hard_shutdown():
    driver.stop()

def graceful_shutdown(signal, frame):
    hard_shutdown()

#
# Execution entry point:
#
if __name__ == "__main__":

    time_label = utils.get_time_label()
    utils.configureLogger(time_label=time_label)
    logger = logging.getLogger(utils.DEFAULT_LOGGER_NAME)

    if len(sys.argv) < 2:
        print "Usage: %s mesosMasterUrl" % sys.argv[0]
        sys.exit(1)

    mesosMasterUrl = sys.argv[1]

    # baseURI = "/home/vagrant/hostfiles"
    baseURI = "/home/vagrant/devfiles"
    suffixURI = "python-mhgh"
    uris = [ "test_executor.py",
             "tasks.py",
             "activity_imitator.py",
             "results.py",