Beispiel #1
0
def run(cmdline_args=None, set_retcode=True):
    cmdline_args = cmdline_args or sys.argv[1:]

    if set_retcode:
        luigi.retcodes.retcode.already_running = 10
        luigi.retcodes.retcode.missing_data = 20
        luigi.retcodes.retcode.not_run = 30
        luigi.retcodes.retcode.task_failed = 40
        luigi.retcodes.retcode.scheduling_error = 50

    read_environ()
    check_config()
    _try_tree_info(cmdline_args)
    _try_to_delete_unnecessary_output_file(cmdline_args)
    gokart.testing.try_to_run_test_for_empty_data_frame(cmdline_args)

    slack_api = _try_get_slack_api(cmdline_args)
    event_aggregator = gokart.slack.EventAggregator()
    try:
        event_aggregator.set_handlers()
        luigi.cmdline.luigi_run(cmdline_args)
    except SystemExit as e:
        _try_to_send_event_summary_to_slack(slack_api, event_aggregator,
                                            cmdline_args)
        sys.exit(e.code)
Beispiel #2
0
def build(task: TaskOnKart,
          verbose: bool = False,
          return_value: bool = True,
          reset_register: bool = True) -> Optional[Any]:
    """
    Run gokart task for local interpreter.
    """
    if reset_register:
        _reset_register()
    read_environ()
    check_config()
    with HideLogger(verbose):
        luigi.build([task], local_scheduler=True)
    return _get_output(task) if return_value else None
Beispiel #3
0
def build(task: TaskOnKart,
          return_value: bool = True,
          reset_register: bool = True,
          log_level: int = logging.ERROR) -> Optional[Any]:
    """
    Run gokart task for local interpreter.
    """
    if reset_register:
        _reset_register()
    read_environ()
    check_config()
    with LoggerConfig(level=log_level):
        result = luigi.build([task],
                             local_scheduler=True,
                             detailed_summary=True)
        if result.status == luigi.LuigiStatusCode.FAILED:
            raise GokartBuildError(result.summary_text)
    return _get_output(task) if return_value else None
Beispiel #4
0
def build(task: TaskOnKart,
          return_value: bool = True,
          reset_register: bool = True,
          log_level: int = logging.ERROR,
          **env_params) -> Optional[Any]:
    """
    Run gokart task for local interpreter.
    Sharing the most of its parameters with luigi.build (see https://luigi.readthedocs.io/en/stable/api/luigi.html?highlight=build#luigi.build)
    """
    if reset_register:
        _reset_register()
    read_environ()
    check_config()
    with LoggerConfig(level=log_level):
        result = luigi.build([task],
                             local_scheduler=True,
                             detailed_summary=True,
                             **env_params)
        if result.status == luigi.LuigiStatusCode.FAILED:
            raise GokartBuildError(result.summary_text)
    return _get_output(task) if return_value else None