Skip to content

Commit a977aea

Browse files
authored
Fix: no models ready to run message shouldn't error (#3644)
1 parent 126b7e4 commit a977aea

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

sqlmesh/core/scheduler.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,17 @@ def run(
313313
)
314314

315315
if not merged_intervals:
316-
next_ready_interval_start = get_next_model_interval_start(self.snapshots.values())
316+
next_run_ready_msg = ""
317317

318-
utc_time = format_tz_datetime(next_ready_interval_start)
319-
local_time = format_tz_datetime(next_ready_interval_start, use_local_timezone=True)
318+
next_ready_interval_start = get_next_model_interval_start(self.snapshots.values())
319+
if next_ready_interval_start:
320+
utc_time = format_tz_datetime(next_ready_interval_start)
321+
local_time = format_tz_datetime(next_ready_interval_start, use_local_timezone=True)
322+
time_msg = local_time if local_time == utc_time else f"{local_time} ({utc_time})"
323+
next_run_ready_msg = f"\n\nNext run will be ready at {time_msg}."
320324

321325
self.console.log_status_update(
322-
f"No models are ready to run. Please wait until a model `cron` interval has elapsed.\n\nNext run will be ready at {local_time} ({utc_time})."
326+
f"No models are ready to run. Please wait until a model `cron` interval has elapsed.{next_run_ready_msg}"
323327
)
324328
return CompletionStatus.NOTHING_TO_DO
325329

sqlmesh/core/snapshot/definition.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,12 +2087,13 @@ def _check_ready_intervals(
20872087
return checked_intervals
20882088

20892089

2090-
def get_next_model_interval_start(snapshots: t.Iterable[Snapshot]) -> datetime:
2090+
def get_next_model_interval_start(snapshots: t.Iterable[Snapshot]) -> t.Optional[datetime]:
20912091
now_dt = now()
2092-
return min(
2093-
[
2094-
snap.node.cron_next(now_dt)
2095-
for snap in snapshots
2096-
if snap.is_model and not snap.is_symbolic and not snap.is_seed
2097-
]
2098-
)
2092+
2093+
starts = [
2094+
snap.node.cron_next(now_dt)
2095+
for snap in snapshots
2096+
if snap.is_model and not snap.is_symbolic and not snap.is_seed
2097+
]
2098+
2099+
return min(starts) if starts else None

0 commit comments

Comments
 (0)