Skip to content

Commit 9af6d98

Browse files
committed
Refactor create_scheduler
1 parent 3cf3946 commit 9af6d98

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

sqlmesh/core/context.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,10 @@ def scheduler(self, environment: t.Optional[str] = None) -> Scheduler:
540540
if not snapshots:
541541
raise ConfigError("No models were found")
542542

543-
return self.create_scheduler(snapshots)
543+
return self.create_scheduler(snapshots, self.snapshot_evaluator())
544544

545545
def create_scheduler(
546-
self, snapshots: t.Iterable[Snapshot], correlation_id: t.Optional[CorrelationId] = None
546+
self, snapshots: t.Iterable[Snapshot], snapshot_evaluator: SnapshotEvaluator
547547
) -> Scheduler:
548548
"""Creates the built-in scheduler.
549549
@@ -555,7 +555,7 @@ def create_scheduler(
555555
"""
556556
return Scheduler(
557557
snapshots,
558-
self.snapshot_evaluator(correlation_id),
558+
snapshot_evaluator,
559559
self.state_sync,
560560
default_catalog=self.default_catalog,
561561
max_workers=self.concurrent_tasks,

sqlmesh/core/plan/evaluator.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
from sqlmesh.utils.concurrency import NodeExecutionFailedError
4242
from sqlmesh.utils.errors import PlanError, SQLMeshError
4343
from sqlmesh.utils.dag import DAG
44-
from sqlmesh.utils import CorrelationId
4544
from sqlmesh.utils.date import now
4645

4746
logger = logging.getLogger(__name__)
@@ -73,7 +72,7 @@ class BuiltInPlanEvaluator(PlanEvaluator):
7372
def __init__(
7473
self,
7574
state_sync: StateSync,
76-
create_scheduler: t.Callable[[t.Iterable[Snapshot], t.Optional[CorrelationId]], Scheduler],
75+
create_scheduler: t.Callable[[t.Iterable[Snapshot], SnapshotEvaluator], Scheduler],
7776
default_catalog: t.Optional[str],
7877
console: t.Optional[Console] = None,
7978
):
@@ -231,9 +230,7 @@ def visit_backfill_stage(self, stage: stages.BackfillStage, plan: EvaluatablePla
231230
self.console.log_success("SKIP: No model batches to execute")
232231
return
233232

234-
scheduler = self.create_scheduler(
235-
stage.all_snapshots.values(), CorrelationId.from_plan_id(plan.plan_id)
236-
)
233+
scheduler = self.create_scheduler(stage.all_snapshots.values(), self.snapshot_evaluator)
237234
errors, _ = scheduler.run_merged_intervals(
238235
merged_intervals=stage.snapshot_to_intervals,
239236
deployability_index=stage.deployability_index,
@@ -254,7 +251,7 @@ def visit_audit_only_run_stage(
254251
return
255252

256253
# If there are any snapshots to be audited, we'll reuse the scheduler's internals to audit them
257-
scheduler = self.create_scheduler(audit_snapshots, CorrelationId.from_plan_id(plan.plan_id))
254+
scheduler = self.create_scheduler(audit_snapshots, self.snapshot_evaluator)
258255
completion_status = scheduler.audit(
259256
plan.environment,
260257
plan.start,

0 commit comments

Comments
 (0)