def resolve_environment_schema_or_error(graphene_info, selector, mode): check.inst_param(graphene_info, 'graphene_info', ResolveInfo) check.inst_param(selector, 'selector', ExecutionSelector) dagster_pipeline = get_dagster_pipeline_from_selector( graphene_info, selector) if not dagster_pipeline.has_mode_definition(mode): raise UserFacingGraphQLError( graphene_info.schema.type_named('ModeNotFoundError')( mode=mode, selector=selector)) return graphene_info.schema.type_named('EnvironmentSchema')( dagster_pipeline=dagster_pipeline, environment_schema=create_environment_schema(dagster_pipeline, mode), )
def resolve_environment_schema_or_error(graphene_info, selector, mode): check.inst_param(graphene_info, 'graphene_info', ResolveInfo) check.inst_param(selector, 'selector', ExecutionSelector) check.opt_str_param(mode, 'mode') pipeline_def = get_pipeline_def_from_selector(graphene_info, selector) if mode is None: mode = pipeline_def.get_default_mode_name() if not pipeline_def.has_mode_definition(mode): raise UserFacingGraphQLError( graphene_info.schema.type_named('ModeNotFoundError')( mode=mode, selector=selector)) return graphene_info.schema.type_named('EnvironmentSchema')( dagster_pipeline=pipeline_def, environment_schema=create_environment_schema(pipeline_def, mode), )
def _launch_pipeline_execution_for_created_run(graphene_info, run_id): check.inst_param(graphene_info, 'graphene_info', ResolveInfo) check.str_param(run_id, 'run_id') # First retrieve the pipeline run instance = graphene_info.context.instance pipeline_run = instance.get_run_by_id(run_id) if not pipeline_run: return graphene_info.schema.type_named('PipelineRunNotFoundError')(run_id) pipeline_def = get_pipeline_def_from_selector(graphene_info, pipeline_run.selector) # Run config valudation # If there are any config errors, then inject them into the event log environment_schema = create_environment_schema(pipeline_def, pipeline_run.mode) validated_config = validate_config( environment_schema.environment_type, pipeline_run.environment_dict ) if not validated_config.success: # If the config is invalid, we construct a DagsterInvalidConfigError exception and # insert it into the event log. We also return a PipelineConfigValidationInvalid user facing # graphql error. # We currently re-use the engine events machinery to add the error to the event log, but # may need to create a new event type and instance method to handle these erros. invalid_config_exception = DagsterInvalidConfigError( 'Error in config for pipeline {}'.format(pipeline_def.name), validated_config.errors, pipeline_run.environment_dict, ) instance.report_engine_event( str(invalid_config_exception.message), pipeline_run, EngineEventData.engine_error( SerializableErrorInfo( invalid_config_exception.message, [], DagsterInvalidConfigError.__class__.__name__, None, ) ), ) instance.report_run_failed(pipeline_run) return DauphinPipelineConfigValidationInvalid.for_validation_errors( pipeline_def.get_pipeline_index(), validated_config.errors ) try: pipeline_run = instance.launch_run(pipeline_run.run_id) except DagsterLaunchFailedError: error = serializable_error_info_from_exc_info(sys.exc_info()) instance.report_engine_event( error.message, pipeline_run, EngineEventData.engine_error(error), ) instance.report_run_failed(pipeline_run) return graphene_info.schema.type_named('LaunchPipelineRunSuccess')( run=graphene_info.schema.type_named('PipelineRun')(pipeline_run) )
def _start_pipeline_execution_for_created_run(graphene_info, run_id): check.inst_param(graphene_info, 'graphene_info', ResolveInfo) instance = graphene_info.context.instance execution_manager_settings = instance.dagit_settings.get( 'execution_manager') if execution_manager_settings and execution_manager_settings.get( 'disabled'): return graphene_info.schema.type_named( 'StartPipelineRunDisabledError')() pipeline_run = instance.get_run_by_id(run_id) if not pipeline_run: return graphene_info.schema.type_named('PipelineRunNotFoundError')( run_id) pipeline_def = get_pipeline_def_from_selector(graphene_info, pipeline_run.selector) environment_schema = create_environment_schema(pipeline_def, pipeline_run.mode) validated_config = validate_config(environment_schema.environment_type, pipeline_run.environment_dict) if not validated_config.success: # If the config is invalid, we construct a DagsterInvalidConfigError exception and # insert it into the event log. We also return a PipelineConfigValidationInvalid user facing # graphql error. # We currently re-use the engine events machinery to add the error to the event log, but # may need to create a new event type and instance method to handle these erros. invalid_config_exception = DagsterInvalidConfigError( 'Error in config for pipeline {}'.format(pipeline_def.name), validated_config.errors, pipeline_run.environment_dict, ) instance.report_engine_event( str(invalid_config_exception.message), pipeline_run, EngineEventData.engine_error( SerializableErrorInfo( invalid_config_exception.message, [], DagsterInvalidConfigError.__class__.__name__, None, )), ) instance.report_run_failed(pipeline_run) return DauphinPipelineConfigValidationInvalid.for_validation_errors( pipeline_def.get_pipeline_index(), validated_config.errors) graphene_info.context.execution_manager.execute_pipeline( graphene_info.context.get_handle(), pipeline_def, pipeline_run, instance=instance, ) return graphene_info.schema.type_named('StartPipelineRunSuccess')( run=graphene_info.schema.type_named('PipelineRun')(pipeline_run))