Skip to content

Commit bacf148

Browse files
committed
fix: adding in run_id injection
Signed-off-by: Cortland Goffena <30168413+cmgoffena13@users.noreply.github.com>
1 parent b43743a commit bacf148

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

sqlmesh/core/context.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
filter_tests_by_patterns,
119119
)
120120
from sqlmesh.core.user import User
121-
from sqlmesh.utils import UniqueKeyDict, Verbosity
121+
from sqlmesh.utils import CorrelationId, UniqueKeyDict, Verbosity
122122
from sqlmesh.utils.concurrency import concurrent_apply_to_values
123123
from sqlmesh.utils.dag import DAG
124124
from sqlmesh.utils.date import (
@@ -811,6 +811,9 @@ def run(
811811
engine_type=self.snapshot_evaluator.adapter.dialect,
812812
state_sync_type=self.state_sync.state_type(),
813813
)
814+
snapshot_evaluator = self.snapshot_evaluator.set_correlation_id(
815+
CorrelationId.from_run_id(analytics_run_id)
816+
)
814817
self._load_materializations()
815818

816819
env_check_attempts_num = max(
@@ -863,6 +866,7 @@ def _has_environment_changed() -> bool:
863866
select_models=select_models,
864867
circuit_breaker=_has_environment_changed,
865868
no_auto_upstream=no_auto_upstream,
869+
snapshot_evaluator=snapshot_evaluator,
866870
)
867871
done = True
868872
except CircuitBreakerError:
@@ -2586,8 +2590,9 @@ def _run(
25862590
select_models: t.Optional[t.Collection[str]],
25872591
circuit_breaker: t.Optional[t.Callable[[], bool]],
25882592
no_auto_upstream: bool,
2593+
snapshot_evaluator: t.Optional[SnapshotEvaluator] = None,
25892594
) -> CompletionStatus:
2590-
scheduler = self.scheduler(environment=environment)
2595+
scheduler = self.scheduler(environment=environment, snapshot_evaluator=snapshot_evaluator)
25912596
snapshots = scheduler.snapshots
25922597

25932598
if select_models is not None:

sqlmesh/utils/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ def __str__(self) -> str:
409409
def from_plan_id(cls, plan_id: str) -> CorrelationId:
410410
return CorrelationId(JobType.PLAN, plan_id)
411411

412+
@classmethod
413+
def from_run_id(cls, run_id: str) -> CorrelationId:
414+
return CorrelationId(JobType.RUN, run_id)
415+
412416

413417
def get_source_columns_to_types(
414418
columns_to_types: t.Dict[str, exp.DataType],

0 commit comments

Comments
 (0)