Skip to content

Commit fddbf4d

Browse files
committed
Store audit results via callback rather than local console reference
1 parent e76ebb8 commit fddbf4d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sqlmesh/core/scheduler.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from sqlmesh.core.console import Console, get_console
88
from sqlmesh.core.environment import EnvironmentNamingInfo, execute_environment_statements
99
from sqlmesh.core.macros import RuntimeStage
10+
from sqlmesh.core.model.definition import AuditResult
1011
from sqlmesh.core.node import IntervalUnit
1112
from sqlmesh.core.notification_target import (
1213
NotificationEvent,
@@ -167,6 +168,7 @@ def evaluate(
167168
batch_index: int,
168169
environment_naming_info: EnvironmentNamingInfo,
169170
default_catalog: t.Optional[str],
171+
on_audits_complete: t.Optional[t.Callable[[Snapshot, t.List[AuditResult]], None]] = None,
170172
**kwargs: t.Any,
171173
) -> None:
172174
"""Evaluate a snapshot and add the processed interval to the state sync.
@@ -207,7 +209,8 @@ def evaluate(
207209
wap_id=wap_id,
208210
**kwargs,
209211
)
210-
get_console().store_evaluation_audit_results(snapshot, audit_results)
212+
if on_audits_complete:
213+
on_audits_complete(snapshot, audit_results)
211214

212215
audit_errors_to_raise: t.List[AuditError] = []
213216
for audit_result in (result for result in audit_results if result.count):
@@ -483,6 +486,7 @@ def evaluate_node(node: SchedulingUnit) -> None:
483486
batch_index=batch_idx,
484487
environment_naming_info=environment_naming_info,
485488
default_catalog=self.default_catalog,
489+
on_audits_complete=self.console.store_evaluation_audit_results,
486490
)
487491
evaluation_duration_ms = now_timestamp() - execution_start_ts
488492
finally:

0 commit comments

Comments
 (0)