Skip to content

Commit 60c1251

Browse files
committed
(external-config-schema-22) Use external pipeline in start_scheduled_execution
Summary: See title Depends on D2822 Test Plan: BK Reviewers: sashank, alangenfeld Reviewed By: sashank Differential Revision: https://dagster.phacility.com/D2832
1 parent 48cb4e6 commit 60c1251

2 files changed

Lines changed: 27 additions & 22 deletions

File tree

python_modules/dagster-graphql/dagster_graphql/implementation/execution/scheduled_execution.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,25 @@
33
import sys
44
import time
55

6-
from dagster_graphql.implementation.fetch_runs import is_config_valid
76
from dagster_graphql.implementation.utils import ExecutionMetadata, ExecutionParams
87
from graphql.execution.base import ResolveInfo
98

109
from dagster import check
10+
from dagster.config.validate import validate_config_from_snap
1111
from dagster.core.definitions.schedule import ScheduleExecutionContext
1212
from dagster.core.errors import (
1313
DagsterUserCodeExecutionError,
1414
ScheduleExecutionError,
1515
user_code_error_boundary,
1616
)
1717
from dagster.core.events import EngineEventData
18-
from dagster.core.execution.api import create_execution_plan
1918
from dagster.core.scheduler import ScheduleTickStatus
2019
from dagster.core.scheduler.scheduler import ScheduleTickData
21-
from dagster.core.snap import snapshot_from_execution_plan
2220
from dagster.core.storage.tags import check_tags
2321
from dagster.utils.error import serializable_error_info_from_exc_info
2422
from 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
2725
from ..fetch_schedules import get_dagster_schedule_def
2826
from ..utils import capture_dauphin_error
2927
from .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

python_modules/dagster-graphql/dagster_graphql/implementation/external.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ def get_preset(self, preset_name):
5252
check.str_param(preset_name, 'preset_name')
5353
return self._active_preset_dict[preset_name]
5454

55+
def get_mode(self, mode_name):
56+
check.str_param(mode_name, 'mode_name')
57+
return self.pipeline_index.get_mode_def_snap(mode_name)
58+
5559
@staticmethod
5660
def from_pipeline_def(pipeline_def):
5761
return ExternalPipeline(

0 commit comments

Comments
 (0)