当前位置: 首页>>代码示例>>Python>>正文


Python cmdline_parser.CmdlineParser类代码示例

本文整理汇总了Python中luigi.cmdline_parser.CmdlineParser的典型用法代码示例。如果您正苦于以下问题:Python CmdlineParser类的具体用法?Python CmdlineParser怎么用?Python CmdlineParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CmdlineParser类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _run

def _run(cmdline_args=None, main_task_cls=None,
         worker_scheduler_factory=None, use_dynamic_argparse=None, local_scheduler=False):
    """
    Please dont use. Instead use `luigi` binary.

    Run from cmdline using argparse.

    :param cmdline_args:
    :param main_task_cls:
    :param worker_scheduler_factory:
    :param use_dynamic_argparse: Deprecated and ignored
    :param local_scheduler:
    """
    if use_dynamic_argparse is not None:
        warnings.warn("use_dynamic_argparse is deprecated, don't set it.",
                      DeprecationWarning, stacklevel=2)
    if cmdline_args is None:
        cmdline_args = sys.argv[1:]

    if main_task_cls:
        cmdline_args.insert(0, main_task_cls.task_family)
    if local_scheduler:
        cmdline_args.insert(0, '--local-scheduler')

    with CmdlineParser.global_instance(cmdline_args) as cp:
        return _schedule_and_run([cp.get_task_obj()], worker_scheduler_factory)
开发者ID:realgo,项目名称:luigi,代码行数:26,代码来源:interface.py

示例2: find_deps_cli

def find_deps_cli():
    '''
    Finds all tasks on all paths from provided CLI task
    '''
    cmdline_args = sys.argv[1:]
    with CmdlineParser.global_instance(cmdline_args) as cp:
        return find_deps(cp.get_task_obj(), upstream().family)
开发者ID:Tarrasch,项目名称:luigi,代码行数:7,代码来源:deps.py

示例3: _value_iterator

    def _value_iterator(self, task_name, param_name):
        """
        Yield the parameter values, with optional deprecation warning as second tuple value.

        The parameter value will be whatever non-_no_value that is yielded first.
        """
        cp_parser = CmdlineParser.get_instance()
        if cp_parser:
            dest = self._parser_global_dest(param_name, task_name)
            found = getattr(cp_parser.known_args, dest, None)
            yield (self._parse_or_no_value(found), None)
        yield (self._get_value_from_config(task_name, param_name), None)
        yield (
            self._get_value_from_config(task_name, param_name.replace("_", "-")),
            "Configuration [{}] {} (with dashes) should be avoided. Please use underscores.".format(
                task_name, param_name
            ),
        )
        if self.__config:
            yield (
                self._get_value_from_config(self.__config["section"], self.__config["name"]),
                "The use of the configuration [{}] {} is deprecated. Please use [{}] {}".format(
                    self.__config["section"], self.__config["name"], task_name, param_name
                ),
            )
        yield (self._default, None)
开发者ID:ryantuck,项目名称:luigi,代码行数:26,代码来源:parameter.py

示例4: find_deps_cli

def find_deps_cli():
    '''
    Finds all tasks on all paths from provided CLI task
    '''
    cmdline_args = sys.argv[1:]
    with CmdlineParser.global_instance(cmdline_args) as cp:
        task_cls = cp.get_task_cls()
        task = task_cls()
        upstream_task_family = upstream().family
        return find_deps(task, upstream_task_family)
开发者ID:nirmeshk,项目名称:luigi,代码行数:10,代码来源:deps.py

示例5: _run

def _run(cmdline_args=None, main_task_cls=None,
         worker_scheduler_factory=None, use_dynamic_argparse=None, local_scheduler=False, detailed_summary=False):
    if use_dynamic_argparse is not None:
        warnings.warn("use_dynamic_argparse is deprecated, don't set it.",
                      DeprecationWarning, stacklevel=2)
    if cmdline_args is None:
        cmdline_args = sys.argv[1:]

    if main_task_cls:
        cmdline_args.insert(0, main_task_cls.task_family)
    if local_scheduler:
        cmdline_args.append('--local-scheduler')
    with CmdlineParser.global_instance(cmdline_args) as cp:
        return _schedule_and_run([cp.get_task_obj()], worker_scheduler_factory)
开发者ID:PeteW,项目名称:luigi,代码行数:14,代码来源:interface.py

示例6: _value_iterator

    def _value_iterator(self, task_name, param_name):
        """
        Yield the parameter values, with optional deprecation warning as second tuple value.

        The parameter value will be whatever non-_no_value that is yielded first.
        """
        cp_parser = CmdlineParser.get_instance()
        if cp_parser:
            dest = self._parser_global_dest(param_name, task_name)
            found = getattr(cp_parser.known_args, dest, None)
            yield (self._parse_or_no_value(found), None)
        yield (self._get_value_from_config(task_name, param_name), None)
        if self._config_path:
            yield (self._get_value_from_config(self._config_path['section'], self._config_path['name']),
                   'The use of the configuration [{}] {} is deprecated. Please use [{}] {}'.format(
                       self._config_path['section'], self._config_path['name'], task_name, param_name))
        yield (self._default, None)
开发者ID:spotify,项目名称:luigi,代码行数:17,代码来源:parameter.py

示例7: main

def main(luigi_module_file, last_task, first_task, dry_run, luigi_args):
    """
    Determines which files are generated by tasks on a "path" of a luigi task graph and deletes them.
    This is useful to force-run one or several tasks as if the output targets already
    exist, luigi will not execute the task.

    For example if there are 4 tasks A -> B -> C -> D ('->' meaning 'requires')
    and the code of task C changed, one might to rerun tasks C, B and A. Hence,
    the output files generated by these three tasks should get deleted first.

    :param luigi_module_file: python module name containing luigi tasks (needs to be on python path)
    :param last_task: last task in topological ordering ('A' in example)
    :param first_task: first task in topological ordering ('C' in example)
    :param dry_run: don't delete files, just output paths
    :param luigi_args: arguments passed to luigi
    """

    luigi_cmd = ['--module', luigi_module_file, last_task]

    if luigi_args:
        luigi_cmd.extend(luigi_args)

    with CmdlineParser.global_instance(luigi_cmd) as cp:
        task = cp.get_task_obj()

        print("Determining output files on path {} to {}".format(first_task, last_task))
        files = walk_tree(task, first_task)

        files_to_delete = {f for f in files if os.path.exists(f)}

        if not files_to_delete:
            print("Nothing to delete.")

        for f in files_to_delete:
            if not dry_run:
                print("Removing {}".format(f))
                os.unlink(f)
            else:
                print("Would remove {}".format(f))
开发者ID:BD2KGenomics,项目名称:brca-exchange,代码行数:39,代码来源:prune_output_files.py

示例8: _value_iterator

    def _value_iterator(self, task_name, param_name):
        """
        Yield the parameter values, with optional deprecation warning as second tuple value.

        The parameter value will be whatever non-_no_value that is yielded first.
        """
        cp_parser = CmdlineParser.get_instance()
        if cp_parser:
            is_without_section = not task_register.Register.get_task_cls(task_name).use_cmdline_section
            globs = [True] + ([False] if cp_parser.is_local_task(task_name) else [])
            for glob in globs:
                dest = self._parser_dest(param_name, task_name, glob=glob, is_without_section=is_without_section)
                if dest:
                    found = getattr(cp_parser.known_args, dest, None)
                    yield (self._parse_or_no_value(found), None)
        yield (self._get_value_from_config(task_name, param_name), None)
        yield (self._get_value_from_config(task_name, param_name.replace('_', '-')),
               'Configuration [{}] {} (with dashes) should be avoided. Please use underscores.'.format(
               task_name, param_name))
        if self.__config:
            yield (self._get_value_from_config(self.__config['section'], self.__config['name']),
                   'The use of the configuration [{}] {} is deprecated. Please use [{}] {}'.format(
                   self.__config['section'], self.__config['name'], task_name, param_name))
        yield (self.__default, None)
开发者ID:nirmeshk,项目名称:luigi,代码行数:24,代码来源:parameter.py

示例9: in_parse

def in_parse(cmds, deferred_computation):
    with CmdlineParser.global_instance(cmds):
        deferred_computation()
开发者ID:nirmeshk,项目名称:luigi,代码行数:3,代码来源:helpers.py

示例10: wrapper

 def wrapper(*args, **kwargs):
     with CmdlineParser.global_instance(self.cmds, allow_override=True):
         return fun(*args, **kwargs)
开发者ID:nirmeshk,项目名称:luigi,代码行数:3,代码来源:helpers.py

示例11: in_parse

def in_parse(cmds, deferred_computation):
    with CmdlineParser.global_instance(cmds) as cp:
        deferred_computation(cp.get_task_obj())
开发者ID:01-,项目名称:luigi,代码行数:3,代码来源:helpers.py

示例12: main

def main():
    cmdline_args = sys.argv[1:]
    with CmdlineParser.global_instance(cmdline_args) as cp:
        task = cp.get_task_obj()
        print(print_tree(task))
开发者ID:Houzz,项目名称:luigi,代码行数:5,代码来源:deps_tree.py


注:本文中的luigi.cmdline_parser.CmdlineParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。