28
28
)
29
29
from sqlmesh .core .snapshot .definition import (
30
30
Interval ,
31
- SnapshotEvaluationTriggers ,
32
31
SnapshotIntervals ,
33
32
check_ready_intervals ,
34
33
expand_range ,
@@ -228,7 +227,6 @@ def run(
228
227
ignore_cron : bool = False ,
229
228
end_bounded : bool = False ,
230
229
selected_snapshots : t .Optional [t .Set [str ]] = None ,
231
- selected_snapshots_auto_upstream : t .Optional [t .Set [str ]] = None ,
232
230
circuit_breaker : t .Optional [t .Callable [[], bool ]] = None ,
233
231
deployability_index : t .Optional [DeployabilityIndex ] = None ,
234
232
auto_restatement_enabled : bool = False ,
@@ -245,7 +243,6 @@ def run(
245
243
ignore_cron = ignore_cron ,
246
244
end_bounded = end_bounded ,
247
245
selected_snapshots = selected_snapshots ,
248
- selected_snapshots_auto_upstream = selected_snapshots_auto_upstream ,
249
246
circuit_breaker = circuit_breaker ,
250
247
deployability_index = deployability_index ,
251
248
auto_restatement_enabled = auto_restatement_enabled ,
@@ -381,7 +378,7 @@ def run_merged_intervals(
381
378
run_environment_statements : bool = False ,
382
379
audit_only : bool = False ,
383
380
restatements : t .Optional [t .Dict [SnapshotId , Interval ]] = None ,
384
- snapshot_evaluation_triggers : t .Dict [SnapshotId , SnapshotEvaluationTriggers ] = {},
381
+ auto_restatement_triggers : t .Dict [SnapshotId , t . List [ SnapshotId ] ] = {},
385
382
) -> t .Tuple [t .List [NodeExecutionFailedError [SchedulingUnit ]], t .List [SchedulingUnit ]]:
386
383
"""Runs precomputed batches of missing intervals.
387
384
@@ -484,9 +481,7 @@ def evaluate_node(node: SchedulingUnit) -> None:
484
481
evaluation_duration_ms ,
485
482
num_audits - num_audits_failed ,
486
483
num_audits_failed ,
487
- snapshot_evaluation_triggers = snapshot_evaluation_triggers .get (
488
- snapshot .snapshot_id
489
- ),
484
+ auto_restatement_triggers = auto_restatement_triggers .get (snapshot .snapshot_id ),
490
485
)
491
486
492
487
try :
@@ -597,7 +592,6 @@ def _run_or_audit(
597
592
ignore_cron : bool = False ,
598
593
end_bounded : bool = False ,
599
594
selected_snapshots : t .Optional [t .Set [str ]] = None ,
600
- selected_snapshots_auto_upstream : t .Optional [t .Set [str ]] = None ,
601
595
circuit_breaker : t .Optional [t .Callable [[], bool ]] = None ,
602
596
deployability_index : t .Optional [DeployabilityIndex ] = None ,
603
597
auto_restatement_enabled : bool = False ,
@@ -621,7 +615,6 @@ def _run_or_audit(
621
615
end_bounded: If set to true, the evaluated intervals will be bounded by the target end date, disregarding lookback,
622
616
allow_partials, and other attributes that could cause the intervals to exceed the target end date.
623
617
selected_snapshots: A set of snapshot names to run. If not provided, all snapshots will be run.
624
- selected_snapshots_auto_upstream: The set of selected_snapshots that were automatically added because they're upstream of a selected snapshot.
625
618
circuit_breaker: An optional handler which checks if the run should be aborted.
626
619
deployability_index: Determines snapshots that are deployable in the context of this render.
627
620
auto_restatement_enabled: Whether to enable auto restatements.
@@ -680,38 +673,9 @@ def _run_or_audit(
680
673
return CompletionStatus .NOTHING_TO_DO
681
674
682
675
merged_intervals_snapshots = {snapshot .snapshot_id for snapshot in merged_intervals }
683
- select_snapshot_triggers : t .Dict [SnapshotId , t .List [SnapshotId ]] = {}
684
- if selected_snapshots and selected_snapshots_auto_upstream :
685
- # actually selected snapshots are their own triggers
686
- selected_snapshots_no_auto_upstream = (
687
- selected_snapshots - selected_snapshots_auto_upstream
688
- )
689
- select_snapshot_triggers = {
690
- s_id : [s_id ]
691
- for s_id in [
692
- snapshot_id
693
- for snapshot_id in merged_intervals_snapshots
694
- if snapshot_id .name in selected_snapshots_no_auto_upstream
695
- ]
696
- }
697
676
698
- # trace upstream by walking downstream on reversed dag
699
- reversed_dag = snapshots_to_dag (self .snapshots .values ()).reversed
700
- for s_id in reversed_dag :
701
- if s_id in merged_intervals_snapshots :
702
- triggers = select_snapshot_triggers .get (s_id , [])
703
- for parent_s_id in reversed_dag .graph .get (s_id , set ()):
704
- triggers .extend (select_snapshot_triggers .get (parent_s_id , []))
705
- select_snapshot_triggers [s_id ] = list (dict .fromkeys (triggers ))
706
-
707
- all_snapshot_triggers : t .Dict [SnapshotId , SnapshotEvaluationTriggers ] = {
708
- s_id : SnapshotEvaluationTriggers (
709
- ignore_cron_flag = ignore_cron ,
710
- cron_ready = s_id not in auto_restated_snapshots ,
711
- auto_restatement_triggers = auto_restatement_triggers .get (s_id , []),
712
- select_snapshot_triggers = select_snapshot_triggers .get (s_id , []),
713
- )
714
- for s_id in merged_intervals_snapshots
677
+ auto_restatement_triggers_dict : t .Dict [SnapshotId , t .List [SnapshotId ]] = {
678
+ s_id : auto_restatement_triggers .get (s_id , []) for s_id in merged_intervals_snapshots
715
679
}
716
680
717
681
errors , _ = self .run_merged_intervals (
@@ -725,7 +689,7 @@ def _run_or_audit(
725
689
run_environment_statements = run_environment_statements ,
726
690
audit_only = audit_only ,
727
691
restatements = remove_intervals ,
728
- snapshot_evaluation_triggers = all_snapshot_triggers ,
692
+ auto_restatement_triggers = auto_restatement_triggers_dict ,
729
693
)
730
694
731
695
return CompletionStatus .FAILURE if errors else CompletionStatus .SUCCESS
0 commit comments