def __process_setup_message(manager, body, message): try: manager_endpoint_util.submit_job(manager, body) except Exception: job_id = __client_job_id_from_body(body) log.warn("Failed to setup job %s obtained via message queue." % job_id) message.ack()
def launch(manager, job_id, command_line, params='{}', dependencies_description='null', setup_params='{}', remote_staging='[]', env='[]'): submit_params = loads(params) setup_params = loads(setup_params) dependencies_description = loads(dependencies_description) env = loads(env) remote_staging = loads(remote_staging) submit_config = dict( job_id=job_id, command_line=command_line, setup_params=setup_params, submit_params=submit_params, dependencies_description=dependencies_description, env=env, remote_staging=remote_staging ) submit_job(manager, submit_config)
def run_task(): try: log.info("Running task %s" % task.task_id.value) task_data = from_base64_json(task.data) manager_options = task_data["manager"] config_builder = LwrManagerConfigBuilder(**manager_options) manager, lwr_app = manager_from_args(config_builder) job_config = task_data["job"] submit_job(manager, job_config) self.__task_update(driver, task, mesos_pb2.TASK_RUNNING) wait_for_job(manager, job_config) self.__task_update(driver, task, mesos_pb2.TASK_FINISHED) lwr_app.shutdown() except Exception: log.exception("Failed to run, update, or monitor task %s" % task) raise
def main(): arg_parser = ArgumentParser(description=DESCRIPTION) arg_parser.add_argument("--file", default=None) arg_parser.add_argument("--base64", default=None) LwrManagerConfigBuilder.populate_options(arg_parser) args = arg_parser.parse_args() config_builder = LwrManagerConfigBuilder(args) manager, app = manager_from_args(config_builder) try: job_config = __load_job_config(args) submit_job(manager, job_config) wait_for_job(manager, job_config) except BaseException: log.exception("Failure submitting or waiting on job.") finally: app.shutdown()