Skip to content

Commit ccae61c

Browse files
committed
rename steps to stages
1 parent 404fa0f commit ccae61c

3 files changed

Lines changed: 259 additions & 259 deletions

File tree

sqlmesh/core/plan/explainer.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from sqlmesh.core.console import Console, TerminalConsole, get_console
1010
from sqlmesh.core.environment import EnvironmentNamingInfo
1111
from sqlmesh.core.plan.definition import EvaluatablePlan, SnapshotIntervals
12-
from sqlmesh.core.plan import steps
12+
from sqlmesh.core.plan import stages
1313
from sqlmesh.core.plan.evaluator import (
1414
PlanEvaluator,
1515
)
@@ -39,16 +39,16 @@ def __init__(
3939
def evaluate(
4040
self, plan: EvaluatablePlan, circuit_breaker: t.Optional[t.Callable[[], bool]] = None
4141
) -> None:
42-
plan_steps = steps.build_plan_steps(plan, self.state_reader, self.default_catalog)
42+
plan_stages = stages.build_plan_stages(plan, self.state_reader, self.default_catalog)
4343
explainer_console = _get_explainer_console(
4444
self.console, plan.environment, self.default_catalog
4545
)
46-
explainer_console.explain(plan_steps)
46+
explainer_console.explain(plan_stages)
4747

4848

4949
class ExplainerConsole(abc.ABC):
5050
@abc.abstractmethod
51-
def explain(self, steps: t.List[steps.PlanStep]) -> None:
51+
def explain(self, stages: t.List[stages.PlanStage]) -> None:
5252
pass
5353

5454

@@ -70,41 +70,41 @@ def __init__(
7070
self.verbosity = verbosity
7171
self.console: RichConsole = console or srich.console
7272

73-
def explain(self, steps: t.List[steps.PlanStep]) -> None:
73+
def explain(self, stages: t.List[stages.PlanStage]) -> None:
7474
tree = Tree("[bold]Explained plan[/bold]")
75-
for step in steps:
76-
handler_name = f"visit_{_to_snake_case(step.__class__.__name__)}"
75+
for stage in stages:
76+
handler_name = f"visit_{_to_snake_case(stage.__class__.__name__)}"
7777
if not hasattr(self, handler_name):
78-
logger.error("Unexpected step: %s", step.__class__.__name__)
78+
logger.error("Unexpected stage: %s", stage.__class__.__name__)
7979
continue
8080
handler = getattr(self, handler_name)
81-
result = handler(step)
81+
result = handler(stage)
8282
if result:
8383
tree.add(self._limit_tree(result))
8484
self.console.print(tree)
8585

86-
def visit_before_all_step(self, step: steps.BeforeAllStep) -> Tree:
86+
def visit_before_all_stage(self, stage: stages.BeforeAllStage) -> Tree:
8787
tree = Tree("[bold]Execute before all statements[/bold]")
88-
for statement in step.statements:
88+
for statement in stage.statements:
8989
tree.add(statement)
9090
return tree
9191

92-
def visit_after_all_step(self, step: steps.AfterAllStep) -> Tree:
92+
def visit_after_all_stage(self, stage: stages.AfterAllStage) -> Tree:
9393
tree = Tree("[bold]Execute after all statements[/bold]")
94-
for statement in step.statements:
94+
for statement in stage.statements:
9595
tree.add(statement)
9696
return tree
9797

98-
def visit_physical_layer_update_step(self, step: steps.PhysicalLayerUpdateStep) -> Tree:
99-
if not step.snapshots:
98+
def visit_physical_layer_update_stage(self, stage: stages.PhysicalLayerUpdateStage) -> Tree:
99+
if not stage.snapshots:
100100
return Tree("[bold]SKIP: No physical layer updates to perform[/bold]")
101101

102102
tree = Tree(
103103
"[bold]Validate SQL and create physical layer tables and views if they do not exist[/bold]"
104104
)
105-
for snapshot in step.snapshots:
105+
for snapshot in stage.snapshots:
106106
is_deployable = (
107-
step.deployability_index.is_deployable(snapshot)
107+
stage.deployability_index.is_deployable(snapshot)
108108
if self.environment_naming_info.name != c.PROD
109109
else True
110110
)
@@ -138,31 +138,31 @@ def visit_physical_layer_update_step(self, step: steps.PhysicalLayerUpdateStep)
138138
tree.add(model_tree)
139139
return tree
140140

141-
def visit_audit_only_run_step(self, step: steps.AuditOnlyRunStep) -> Tree:
141+
def visit_audit_only_run_stage(self, stage: stages.AuditOnlyRunStage) -> Tree:
142142
tree = Tree("[bold]Audit-only execution[/bold]")
143-
for snapshot in step.snapshots:
143+
for snapshot in stage.snapshots:
144144
display_name = self._display_name(snapshot)
145145
tree.add(display_name)
146146
return tree
147147

148-
def visit_restatement_step(self, step: steps.RestatementStep) -> Tree:
148+
def visit_restatement_stage(self, stage: stages.RestatementStage) -> Tree:
149149
tree = Tree("[bold]Invalidate data intervals as part of restatement[/bold]")
150-
for snapshot_table_info, interval in step.snapshot_intervals.items():
150+
for snapshot_table_info, interval in stage.snapshot_intervals.items():
151151
display_name = self._display_name(snapshot_table_info)
152152
tree.add(f"{display_name} [{to_ts(interval[0])} - {to_ts(interval[1])}]")
153153
return tree
154154

155-
def visit_backfill_step(self, step: steps.BackfillStep) -> Tree:
156-
if not step.snapshot_to_intervals:
155+
def visit_backfill_stage(self, stage: stages.BackfillStage) -> Tree:
156+
if not stage.snapshot_to_intervals:
157157
return Tree("[bold]SKIP: No model batches to execute[/bold]")
158158

159159
tree = Tree(
160160
"[bold]Backfill models by running their queries and run standalone audits[/bold]"
161161
)
162-
for snapshot, intervals in step.snapshot_to_intervals.items():
162+
for snapshot, intervals in stage.snapshot_to_intervals.items():
163163
display_name = self._display_name(snapshot)
164164
if snapshot.is_model:
165-
table_name = snapshot.table_name(step.deployability_index.is_deployable(snapshot))
165+
table_name = snapshot.table_name(stage.deployability_index.is_deployable(snapshot))
166166
model_tree = Tree(f"{display_name} -> {table_name}")
167167

168168
for signal_name, _ in snapshot.model.signals:
@@ -174,7 +174,7 @@ def visit_backfill_step(self, step: steps.BackfillStep) -> Tree:
174174
if snapshot.is_incremental:
175175
current_intervals = (
176176
snapshot.intervals
177-
if step.deployability_index.is_deployable(snapshot)
177+
if stage.deployability_index.is_deployable(snapshot)
178178
else snapshot.dev_intervals
179179
)
180180
if current_intervals:
@@ -204,43 +204,43 @@ def visit_backfill_step(self, step: steps.BackfillStep) -> Tree:
204204
tree.add(f"{display_name} \[standalone audit]")
205205
return tree
206206

207-
def visit_migrate_schemas_step(self, step: steps.MigrateSchemasStep) -> Tree:
207+
def visit_migrate_schemas_stage(self, stage: stages.MigrateSchemasStage) -> Tree:
208208
tree = Tree(
209209
"[bold]Update schemas (add, drop, alter columns) of production physical tables to reflect forward-only changes[/bold]"
210210
)
211-
for snapshot in step.snapshots:
211+
for snapshot in stage.snapshots:
212212
display_name = self._display_name(snapshot)
213213
table_name = snapshot.table_name(True)
214214
tree.add(f"{display_name} -> {table_name}")
215215
return tree
216216

217-
def visit_virtual_layer_update_step(self, step: steps.VirtualLayerUpdateStep) -> Tree:
217+
def visit_virtual_layer_update_stage(self, stage: stages.VirtualLayerUpdateStage) -> Tree:
218218
tree = Tree(
219219
f"[bold]Update the virtual layer for environment '{self.environment_naming_info.name}'[/bold]"
220220
)
221221
promote_tree = Tree(
222222
"[bold]Create or update views in the virtual layer to point at new physical tables and views[/bold]"
223223
)
224-
for snapshot in step.promoted_snapshots:
224+
for snapshot in stage.promoted_snapshots:
225225
display_name = self._display_name(snapshot)
226-
table_name = snapshot.table_name(step.deployability_index.is_representative(snapshot))
226+
table_name = snapshot.table_name(stage.deployability_index.is_representative(snapshot))
227227
promote_tree.add(f"{display_name} -> {table_name}")
228228

229229
demote_tree = Tree(
230230
"[bold]Delete views in the virtual layer for models that were removed[/bold]"
231231
)
232-
for snapshot in step.demoted_snapshots:
232+
for snapshot in stage.demoted_snapshots:
233233
display_name = self._display_name(snapshot)
234234
demote_tree.add(display_name)
235235

236-
if step.promoted_snapshots:
236+
if stage.promoted_snapshots:
237237
tree.add(self._limit_tree(promote_tree))
238-
if step.demoted_snapshots:
238+
if stage.demoted_snapshots:
239239
tree.add(self._limit_tree(demote_tree))
240240
return tree
241241

242-
def visit_environment_record_update_step(
243-
self, step: steps.EnvironmentRecordUpdateStep
242+
def visit_environment_record_update_stage(
243+
self, stage: stages.EnvironmentRecordUpdateStage
244244
) -> t.Optional[Tree]:
245245
return None
246246

0 commit comments

Comments
 (0)