Ejemplo n.º 1
0
    def test_auto_complete_renew(self):
        @task
        def my_task_autocomplete(a):
            # type: (int)->str
            """
            my task help
            """
            return "ok"

        task_registry = get_task_registry()
        task_classes = task_registry.list_dbnd_task_classes()
        logging.info("task_classes: %s", list(task_registry.list_dbnd_task_classes()))
        completer.refresh(task_classes)
        task_completer = completer.task()
        actual = task_completer(None, None, "my_tas")
        assert actual == [("my_task_autocomplete", "my task help")]
Ejemplo n.º 2
0
    original_name = original_cls.task_definition.task_family
    logger.info("Creating new class %s from %s", new_cls_name, original_name)
    attributes = {}  # {'_conf__task_family': original_cls.get_task_family()}
    if original_cls._conf__decorator_spec:
        conf__decorator_spec = attr.evolve(
            original_cls._conf__decorator_spec, name=new_cls_name
        )
        attributes["_conf__decorator_spec"] = conf__decorator_spec
    else:
        attributes["_conf__task_family"] = new_cls_name
    new_cls = TaskMetaclass(str(new_cls_name), (original_cls,), attributes)
    return new_cls


@click.command(context_settings=dict(help_option_names=[]))
@click.argument("task", autocompletion=completer.task(), required=False)
@click.option("--module", "-m", help="Used for dynamic loading of modules")
@click.option(
    "--set",
    "-s",
    "_sets",
    help="Set configuration value (task_name.task_parameter=value)",
    type=ConfigValueType(),
    multiple=True,
    autocompletion=completer.task_param(),
)
@click.option(
    "--set-config",
    "-c",
    "_sets_config",
    help="Set configuration value (key=value)",
Ejemplo n.º 3
0
from dbnd._core.cli.service_auto_completer import completer
from dbnd._core.task_build.task_registry import get_task_registry
from dbnd._vendor import click


@click.command()
@click.argument("search", default="", autocompletion=completer.config())
@click.option("--module", "-m", help="Used for dynamic loading of modules")
@click.pass_context
def show_configs(ctx, module, search):
    """Show and search configurations"""
    _list_tasks(ctx, module, search, is_config=True)


@click.command()
@click.argument("search", default="", autocompletion=completer.task())
@click.option("--module", "-m", help="Used for dynamic loading of modules")
@click.pass_context
def show_tasks(ctx, module, search):
    """Show and search tasks"""
    _list_tasks(ctx, module, search, is_config=False)


COMMON_PARAMS = {"task_version", "task_env", "task_target_date"}


def _list_tasks(ctx, module, search, is_config):
    from dbnd import Config
    from dbnd._core.parameter.parameter_definition import _ParameterKind
    from dbnd._core.context.databand_context import new_dbnd_context