Skip to content

Commit 82c06ff

Browse files
committed
PR feedback
1 parent 86bec95 commit 82c06ff

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

sqlmesh/core/scheduler.py

+19-15
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,8 @@ def evaluate(
166166
execution_time: TimeLike,
167167
deployability_index: DeployabilityIndex,
168168
batch_index: int,
169-
environment_naming_info: EnvironmentNamingInfo,
170-
default_catalog: t.Optional[str],
171169
**kwargs: t.Any,
172-
) -> t.List[AuditResult]:
170+
) -> t.Tuple[t.List[AuditResult], t.List[AuditError]]:
173171
"""Evaluate a snapshot and add the processed interval to the state sync.
174172
175173
Args:
@@ -213,6 +211,7 @@ def evaluate(
213211
)
214212

215213
audit_errors_to_raise: t.List[AuditError] = []
214+
audit_errors_to_warn: t.List[AuditError] = []
216215
for audit_result in (result for result in audit_results if result.count):
217216
error = AuditError(
218217
audit_name=audit_result.audit.name,
@@ -230,21 +229,13 @@ def evaluate(
230229
if audit_result.blocking:
231230
audit_errors_to_raise.append(error)
232231
else:
233-
display_name = snapshot.display_name(
234-
environment_naming_info,
235-
default_catalog,
236-
self.snapshot_evaluator.adapter.dialect,
237-
)
238-
self.console.log_warning(
239-
f"\n{display_name}: {error}.",
240-
f"{error}. Audit query:\n{error.query.sql(error.adapter_dialect)}",
241-
)
232+
audit_errors_to_warn.append(error)
242233

243234
if audit_errors_to_raise:
244235
raise NodeAuditsErrors(audit_errors_to_raise)
245236

246237
self.state_sync.add_interval(snapshot, start, end, is_dev=not is_deployable)
247-
return audit_results
238+
return audit_results, audit_errors_to_warn
248239

249240
def run(
250241
self,
@@ -475,11 +466,12 @@ def evaluate_node(node: SchedulingUnit) -> None:
475466
execution_start_ts = now_timestamp()
476467
evaluation_duration_ms: t.Optional[int] = None
477468

469+
audit_results: t.List[AuditResult] = []
470+
audit_errors_to_warn: t.List[AuditError] = []
478471
try:
479472
assert execution_time # mypy
480473
assert deployability_index # mypy
481-
audit_results = [] # so it exists for finally if `evaluate` raises
482-
audit_results = self.evaluate(
474+
audit_results, audit_errors_to_warn = self.evaluate(
483475
snapshot=snapshot,
484476
start=start,
485477
end=end,
@@ -489,6 +481,18 @@ def evaluate_node(node: SchedulingUnit) -> None:
489481
environment_naming_info=environment_naming_info,
490482
default_catalog=self.default_catalog,
491483
)
484+
485+
for audit_error in audit_errors_to_warn:
486+
display_name = snapshot.display_name(
487+
environment_naming_info,
488+
self.default_catalog,
489+
self.snapshot_evaluator.adapter.dialect,
490+
)
491+
self.console.log_warning(
492+
f"\n{display_name}: {audit_error}.",
493+
f"{audit_error}. Audit query:\n{audit_error.query.sql(audit_error.adapter_dialect)}",
494+
)
495+
492496
evaluation_duration_ms = now_timestamp() - execution_start_ts
493497
finally:
494498
num_audits = len(audit_results)

tests/core/test_scheduler.py

-2
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,6 @@ def _evaluate():
528528
to_datetime("2022-01-03"),
529529
DeployabilityIndex.all_deployable(),
530530
0,
531-
EnvironmentNamingInfo(),
532-
None,
533531
)
534532

535533
evaluator_audit_mock.return_value = [

0 commit comments

Comments
 (0)