Exemple #1
0
def get_reconstructable_pipeline_from_selector(graphene_info, selector):
    check.inst_param(graphene_info, 'graphene_info', ResolveInfo)
    check.inst_param(selector, 'selector', ExecutionSelector)

    check.invariant(
        isinstance(graphene_info.context,
                   DagsterGraphQLInProcessRepositoryContext),
        'Can only get definition objects in process',
    )

    pipeline_name = selector.name

    # for error check of pipeline existence
    get_full_external_pipeline_or_raise(graphene_info, pipeline_name)

    recon_pipeline = graphene_info.context.get_reconstructable_pipeline(
        pipeline_name)

    if not selector.solid_subset:
        return recon_pipeline

    # for error checking
    get_external_pipeline_or_raise(graphene_info, selector.name,
                                   selector.solid_subset)
    return recon_pipeline.subset_for_execution(selector.solid_subset)
Exemple #2
0
def get_pipeline_snapshot_or_error_from_pipeline_name(graphene_info,
                                                      pipeline_name):
    check.str_param(pipeline_name, 'pipeline_name')
    return DauphinPipelineSnapshot(
        get_full_external_pipeline_or_raise(
            graphene_info,
            PipelineSelector.legacy(graphene_info.context,
                                    pipeline_name,
                                    solid_subset=None),
        ))
def get_reconstructable_pipeline_from_selector(graphene_info, selector):
    check.inst_param(graphene_info, 'graphene_info', ResolveInfo)
    check.inst_param(selector, 'selector', ExecutionSelector)

    pipeline_name = selector.name

    # for error check of pipeline existence
    get_full_external_pipeline_or_raise(graphene_info, pipeline_name)

    recon_pipeline = graphene_info.context.get_reconstructable_pipeline(
        pipeline_name)

    if not selector.solid_subset:
        return recon_pipeline

    # for error checking
    get_external_pipeline_or_raise(graphene_info, selector.name,
                                   selector.solid_subset)
    return recon_pipeline.subset_for_execution(selector.solid_subset)
Exemple #4
0
def create_execution_params(graphene_info, graphql_execution_params):
    preset_name = graphql_execution_params.get('preset')
    selector = pipeline_selector_from_graphql(
        graphene_info.context, graphql_execution_params['selector']
    )
    if preset_name:
        if graphql_execution_params.get('runConfigData'):
            raise UserFacingGraphQLError(
                graphene_info.schema.type_named('ConflictingExecutionParamsError')(
                    conflicting_param='runConfigData'
                )
            )

        if graphql_execution_params.get('mode'):
            raise UserFacingGraphQLError(
                graphene_info.schema.type_named('ConflictingExecutionParamsError')(
                    conflicting_param='mode'
                )
            )

        if selector.solid_selection:
            raise UserFacingGraphQLError(
                graphene_info.schema.type_named('ConflictingExecutionParamsError')(
                    conflicting_param='selector.solid_selection'
                )
            )

        external_pipeline = get_full_external_pipeline_or_raise(graphene_info, selector)

        if not external_pipeline.has_preset(preset_name):
            raise UserFacingGraphQLError(
                graphene_info.schema.type_named('PresetNotFoundError')(
                    preset=preset_name, selector=selector
                )
            )

        preset = external_pipeline.get_preset(preset_name)

        return ExecutionParams(
            selector=selector.with_solid_selection(preset.solid_selection),
            run_config=preset.run_config,
            mode=preset.mode,
            execution_metadata=create_execution_metadata(
                graphql_execution_params.get('executionMetadata')
            ),
            step_keys=graphql_execution_params.get('stepKeys'),
        )

    return execution_params_from_graphql(graphene_info.context, graphql_execution_params)
Exemple #5
0
def create_execution_params(graphene_info, graphql_execution_params):

    preset_name = graphql_execution_params.get('preset')
    selector = pipeline_selector_from_graphql(
        graphene_info.context, graphql_execution_params['selector'])
    if preset_name:
        # This should return proper GraphQL errors
        # https://github.com/dagster-io/dagster/issues/2507
        check.invariant(
            not graphql_execution_params.get('runConfigData'),
            'Invalid ExecutionParams. Cannot define environment_dict when using preset',
        )
        check.invariant(
            not graphql_execution_params.get('mode'),
            'Invalid ExecutionParams. Cannot define mode when using preset',
        )

        check.invariant(
            not selector.solid_selection,
            'Invalid ExecutionParams. Cannot define selector.solid_selection when using preset',
        )

        external_pipeline = get_full_external_pipeline_or_raise(
            graphene_info, selector)

        if not external_pipeline.has_preset(preset_name):
            raise UserFacingGraphQLError(
                graphene_info.schema.type_named('PresetNotFoundError')(
                    preset=preset_name, selector=selector))

        preset = external_pipeline.get_preset(preset_name)

        return ExecutionParams(
            selector=selector.with_solid_selection(preset.solid_selection),
            environment_dict=preset.environment_dict,
            mode=preset.mode,
            execution_metadata=create_execution_metadata(
                graphql_execution_params.get('executionMetadata')),
            step_keys=graphql_execution_params.get('stepKeys'),
        )

    return execution_params_from_graphql(graphene_info.context,
                                         graphql_execution_params)
Exemple #6
0
def create_execution_params(graphene_info, graphql_execution_params):

    preset_name = graphql_execution_params.get('preset')
    if preset_name:
        check.invariant(
            not graphql_execution_params.get('environmentConfigData'),
            'Invalid ExecutionParams. Cannot define environment_dict when using preset',
        )
        check.invariant(
            not graphql_execution_params.get('mode'),
            'Invalid ExecutionParams. Cannot define mode when using preset',
        )

        selector = graphql_execution_params['selector'].to_selector()
        check.invariant(
            not selector.solid_subset,
            'Invalid ExecutionParams. Cannot define selector.solid_subset when using preset',
        )

        external_pipeline = get_full_external_pipeline_or_raise(
            graphene_info, selector.name)

        if not external_pipeline.has_preset(preset_name):
            raise UserFacingGraphQLError(
                graphene_info.schema.type_named('PresetNotFoundError')(
                    preset=preset_name, selector=selector))

        preset = external_pipeline.get_preset(preset_name)

        return ExecutionParams(
            selector=ExecutionSelector(selector.name, preset.solid_subset),
            environment_dict=preset.environment_dict,
            mode=preset.mode,
            execution_metadata=create_execution_metadata(
                graphql_execution_params.get('executionMetadata')),
            step_keys=graphql_execution_params.get('stepKeys'),
        )

    return execution_params_from_graphql(graphql_execution_params)
Exemple #7
0
def get_pipeline_snapshot_or_error_from_pipeline_selector(
        graphene_info, pipeline_selector):
    check.inst_param(pipeline_selector, 'pipeline_selector', PipelineSelector)
    return DauphinPipelineSnapshot(
        get_full_external_pipeline_or_raise(graphene_info, pipeline_selector))
Exemple #8
0
def get_pipeline_snapshot_or_error_from_pipeline_name(graphene_info,
                                                      pipeline_name):
    check.str_param(pipeline_name, 'pipeline_name')
    return DauphinPipelineSnapshot(
        get_full_external_pipeline_or_raise(graphene_info, pipeline_name))