Skip to content

Commit b5424e8

Browse files
committed
Refactor to from_plan_id
1 parent ff1af07 commit b5424e8

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

sqlmesh/core/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,7 @@ def apply(
15971597
explainer.evaluate(
15981598
plan.to_evaluatable(),
15991599
snapshot_evaluator=self.snapshot_evaluator(
1600-
correlation_id=CorrelationId.from_plan(plan)
1600+
correlation_id=CorrelationId.from_plan_id(plan.plan_id)
16011601
),
16021602
)
16031603
return
@@ -2405,7 +2405,7 @@ def _apply(self, plan: Plan, circuit_breaker: t.Optional[t.Callable[[], bool]])
24052405
self._scheduler.create_plan_evaluator(self).evaluate(
24062406
plan.to_evaluatable(),
24072407
snapshot_evaluator=self.snapshot_evaluator(
2408-
correlation_id=CorrelationId.from_plan(plan)
2408+
correlation_id=CorrelationId.from_plan_id(plan.plan_id)
24092409
),
24102410
circuit_breaker=circuit_breaker,
24112411
)

sqlmesh/utils/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626

2727
logger = logging.getLogger(__name__)
2828

29-
if t.TYPE_CHECKING:
30-
from sqlmesh.core.plan import Plan
31-
3229
T = t.TypeVar("T")
3330
KEY = t.TypeVar("KEY", bound=t.Hashable)
3431
VALUE = t.TypeVar("VALUE")
@@ -404,5 +401,5 @@ def __str__(self) -> str:
404401
return f"{self.job_type.value}: {self.job_id}"
405402

406403
@classmethod
407-
def from_plan(cls, plan: Plan) -> CorrelationId:
408-
return CorrelationId(JobType.PLAN, plan.plan_id)
404+
def from_plan_id(cls, plan_id: str) -> CorrelationId:
405+
return CorrelationId(JobType.PLAN, plan_id)

tests/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ def push_plan(context: Context, plan: Plan) -> None:
269269
context.create_scheduler,
270270
context.default_catalog,
271271
)
272-
plan_evaluator.snapshot_evaluator = context.snapshot_evaluator(CorrelationId.from_plan(plan))
272+
plan_evaluator.snapshot_evaluator = context.snapshot_evaluator(
273+
CorrelationId.from_plan_id(plan.plan_id)
274+
)
273275
deployability_index = DeployabilityIndex.create(context.snapshots.values())
274276
evaluatable_plan = plan.to_evaluatable()
275277
stages = plan_stages.build_plan_stages(

tests/core/test_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6484,7 +6484,7 @@ def _correlation_id_in_sqls(correlation_id: CorrelationId, mock_logger):
64846484
ctx = Context(paths=[tmp_path], config=Config())
64856485
plan = ctx.plan(auto_apply=True, no_prompts=True)
64866486

6487-
correlation_id = CorrelationId.from_plan(plan)
6487+
correlation_id = CorrelationId.from_plan_id(plan.plan_id)
64886488
assert str(correlation_id) == f"SQLMESH_PLAN: {plan.plan_id}"
64896489

64906490
assert _correlation_id_in_sqls(correlation_id, mock_logger)

tests/core/test_plan_evaluator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ def test_builtin_evaluator_push(sushi_context: Context, make_snapshot):
6464
sushi_context.default_catalog,
6565
console=sushi_context.console,
6666
)
67-
evaluator.snapshot_evaluator = sushi_context.snapshot_evaluator(CorrelationId.from_plan(plan))
67+
evaluator.snapshot_evaluator = sushi_context.snapshot_evaluator(
68+
CorrelationId.from_plan_id(plan.plan_id)
69+
)
6870

6971
evaluatable_plan = plan.to_evaluatable()
7072
stages = plan_stages.build_plan_stages(

0 commit comments

Comments
 (0)