Пример #1
0
def ui(text, file, predefined, variables, remote, output, remap_sigterm,
       **kwargs):
    query = None
    if text is not None and file is None and predefined is None:
        query = text.strip("'\" \n\t")
    elif file is not None and text is None and predefined is None:
        query = file.read()
    elif predefined is not None and text is None and file is None:
        query = PREDEFINED_QUERIES[predefined]
    else:
        raise click.UsageError(
            "Must select one and only one of text (-t), file (-f), or predefined (-p) "
            "to select GraphQL document to execute.")

    if remap_sigterm:
        signal.signal(signal.SIGTERM, signal.getsignal(signal.SIGINT))

    if remote:
        res = execute_query_against_remote(remote, query, variables)
        print(res)  # pylint: disable=print-call
    else:
        instance = DagsterInstance.get()
        with get_workspace_from_kwargs(kwargs, instance) as workspace:
            execute_query_from_cli(
                workspace,
                query,
                instance,
                variables,
                output,
            )
Пример #2
0
def execute_backfill_command(cli_args,
                             print_fn,
                             instance,
                             using_graph_job_op_apis=False):
    with get_workspace_from_kwargs(instance,
                                   version=dagster_version,
                                   kwargs=cli_args) as workspace:
        repo_location = get_repository_location_from_workspace(
            workspace, cli_args.get("location"))
        _execute_backfill_command_at_location(cli_args, print_fn, instance,
                                              workspace, repo_location,
                                              using_graph_job_op_apis)
Пример #3
0
def execute_launch_command(instance: DagsterInstance,
                           kwargs: Dict[str, str],
                           using_job_op_graph_apis: bool = False):
    preset = cast(Optional[str], kwargs.get("preset"))
    mode = cast(Optional[str], kwargs.get("mode"))
    check.inst_param(instance, "instance", DagsterInstance)
    config = get_config_from_args(kwargs)

    with get_workspace_from_kwargs(instance,
                                   version=dagster_version,
                                   kwargs=kwargs) as workspace:
        repo_location = get_repository_location_from_workspace(
            workspace, kwargs.get("location"))
        external_repo = get_external_repository_from_repo_location(
            repo_location, cast(Optional[str], kwargs.get("repository")))
        external_pipeline = get_external_pipeline_or_job_from_external_repo(
            external_repo,
            cast(Optional[str], kwargs.get("pipeline_or_job")),
            using_job_op_graph_apis,
        )

        log_external_repo_stats(
            instance=instance,
            external_pipeline=external_pipeline,
            external_repo=external_repo,
            source="pipeline_launch_command",
        )

        if preset and config:
            raise click.UsageError(
                "Can not use --preset with -c / --config / --config-json.")

        run_tags = get_tags_from_args(kwargs)

        solid_selection = get_solid_selection_from_args(kwargs)

        pipeline_run = _create_external_pipeline_run(
            instance=instance,
            repo_location=repo_location,
            external_repo=external_repo,
            external_pipeline=external_pipeline,
            run_config=config,
            mode=mode,
            preset=preset,
            tags=run_tags,
            solid_selection=solid_selection,
            run_id=cast(Optional[str], kwargs.get("run_id")),
        )

        return instance.submit_run(pipeline_run.run_id, workspace)
Пример #4
0
def ui(text, file, predefined, variables, remote, output, **kwargs):
    query = None
    if text is not None and file is None and predefined is None:
        query = text.strip('\'" \n\t')
    elif file is not None and text is None and predefined is None:
        query = file.read()
    elif predefined is not None and text is None and file is None:
        query = PREDEFINED_QUERIES[predefined]
    else:
        raise click.UsageError(
            'Must select one and only one of text (-t), file (-f), or predefined (-p) '
            'to select GraphQL document to execute.')

    if remote:
        res = execute_query_against_remote(remote, query, variables)
        print(res)
    else:
        workspace = get_workspace_from_kwargs(kwargs)
        execute_query_from_cli(workspace, query, variables, output)
Пример #5
0
def ui(text, file, predefined, variables, remote, output, remap_sigterm,
       **kwargs):
    query = None
    if text is not None and file is None and predefined is None:
        query = text.strip("'\" \n\t")
    elif file is not None and text is None and predefined is None:
        query = file.read()
    elif predefined is not None and text is None and file is None:
        query = PREDEFINED_QUERIES[predefined]
    else:
        raise click.UsageError(
            "Must select one and only one of text (-t), file (-f), or predefined (-p) "
            "to select GraphQL document to execute.")

    if remap_sigterm:
        try:
            signal.signal(signal.SIGTERM, signal.getsignal(signal.SIGINT))
        except ValueError:
            warnings.warn((
                "Unexpected error attempting to manage signal handling on thread {thread_name}. "
                "You should not invoke this API (ui) from threads "
                "other than the main thread.").format(
                    thread_name=threading.current_thread().name))

    if remote:
        res = execute_query_against_remote(remote, query, variables)
        print(res)  # pylint: disable=print-call
    else:
        instance = DagsterInstance.get()
        with get_workspace_from_kwargs(kwargs) as workspace:
            execute_query_from_cli(
                workspace,
                query,
                instance,
                variables,
                output,
            )