33import sys
44import time
55
6- from dagster_graphql .implementation .fetch_runs import is_config_valid
76from dagster_graphql .implementation .utils import ExecutionMetadata , ExecutionParams
87from graphql .execution .base import ResolveInfo
98
109from dagster import check
10+ from dagster .config .validate import validate_config_from_snap
1111from dagster .core .definitions .schedule import ScheduleExecutionContext
1212from dagster .core .errors import (
1313 DagsterUserCodeExecutionError ,
1414 ScheduleExecutionError ,
1515 user_code_error_boundary ,
1616)
1717from dagster .core .events import EngineEventData
18- from dagster .core .execution .api import create_execution_plan
1918from dagster .core .scheduler import ScheduleTickStatus
2019from dagster .core .scheduler .scheduler import ScheduleTickData
21- from dagster .core .snap import snapshot_from_execution_plan
2220from dagster .core .storage .tags import check_tags
2321from dagster .utils .error import serializable_error_info_from_exc_info
2422from dagster .utils .merger import merge_dicts
2523
26- from ..fetch_pipelines import get_pipeline_def_from_selector
24+ from ..external import ExternalPipeline , get_external_pipeline_subset_or_raise
2725from ..fetch_schedules import get_dagster_schedule_def
2826from ..utils import capture_dauphin_error
2927from .launch_execution import _launch_pipeline_execution_for_created_run
@@ -104,8 +102,10 @@ def start_scheduled_execution(graphene_info, schedule_name):
104102 error_data = serializable_error_info_from_exc_info (sys .exc_info ())
105103 errors .append (error_data )
106104
107- pipeline_def = get_pipeline_def_from_selector (graphene_info , schedule_def .selector )
108- pipeline_tags = pipeline_def .tags or {}
105+ external_pipeline = get_external_pipeline_subset_or_raise (
106+ graphene_info , schedule_def .selector .name , schedule_def .selector .solid_subset
107+ )
108+ pipeline_tags = external_pipeline .tags or {}
109109 check_tags (pipeline_tags , 'pipeline_tags' )
110110 tags = merge_dicts (pipeline_tags , schedule_tags )
111111
@@ -120,7 +120,7 @@ def start_scheduled_execution(graphene_info, schedule_name):
120120 step_keys = None ,
121121 )
122122
123- run , result = _execute_schedule (graphene_info , pipeline_def , execution_params , errors )
123+ run , result = _execute_schedule (graphene_info , external_pipeline , execution_params , errors )
124124 graphene_info .context .instance .update_schedule_tick (
125125 repository , tick .with_status (ScheduleTickStatus .SUCCESS , run_id = run .run_id ),
126126 )
@@ -138,34 +138,35 @@ def start_scheduled_execution(graphene_info, schedule_name):
138138 raise exc
139139
140140
141- def _execute_schedule (graphene_info , pipeline_def , execution_params , errors ):
141+ def _execute_schedule (graphene_info , external_pipeline , execution_params , errors ):
142+ check .inst_param (external_pipeline , 'external_pipeline' , ExternalPipeline )
142143
143144 instance = graphene_info .context .instance
144145
145- execution_plan = None
146- if is_config_valid (pipeline_def , execution_params .environment_dict , execution_params .mode ):
147- execution_plan = create_execution_plan (
148- pipeline_def , execution_params .environment_dict , mode = execution_params .mode ,
149- )
146+ mode , environment_dict = execution_params .mode , execution_params .environment_dict
150147
151- execution_plan_snapshot = None
152- if execution_plan :
153- execution_plan_snapshot = snapshot_from_execution_plan (
154- execution_plan , pipeline_def .get_pipeline_snapshot_id ()
148+ validation_result = validate_config_from_snap (
149+ external_pipeline .config_schema_snapshot ,
150+ external_pipeline .get_mode (mode ).root_config_key ,
151+ environment_dict ,
152+ )
153+ if validation_result .success :
154+ execution_plan_index = graphene_info .context .create_execution_plan_index (
155+ external_pipeline , environment_dict , mode ,
155156 )
156157
157158 pipeline_run = instance .create_run (
158- pipeline_name = pipeline_def .name ,
159- environment_dict = execution_params . environment_dict ,
160- mode = execution_params . mode ,
159+ pipeline_name = external_pipeline .name ,
160+ environment_dict = environment_dict ,
161+ mode = mode ,
161162 solid_subset = (
162163 execution_params .selector .solid_subset
163164 if execution_params .selector is not None
164165 else None
165166 ),
166167 tags = execution_params .execution_metadata .tags ,
167- pipeline_snapshot = pipeline_def . get_pipeline_snapshot () ,
168- execution_plan_snapshot = execution_plan_snapshot ,
168+ pipeline_snapshot = external_pipeline . pipeline_snapshot ,
169+ execution_plan_snapshot = execution_plan_index . execution_plan_snapshot ,
169170 )
170171
171172 # Inject errors into event log at this point
0 commit comments