Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions sqlmesh/core/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,17 @@ def run(
)

if not merged_intervals:
next_ready_interval_start = get_next_model_interval_start(self.snapshots.values())
next_run_ready_msg = ""

utc_time = format_tz_datetime(next_ready_interval_start)
local_time = format_tz_datetime(next_ready_interval_start, use_local_timezone=True)
next_ready_interval_start = get_next_model_interval_start(self.snapshots.values())
if next_ready_interval_start:
utc_time = format_tz_datetime(next_ready_interval_start)
local_time = format_tz_datetime(next_ready_interval_start, use_local_timezone=True)
time_msg = local_time if local_time == utc_time else f"{local_time} ({utc_time})"
next_run_ready_msg = f"\n\nNext run will be ready at {time_msg}."

self.console.log_status_update(
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})."
f"No models are ready to run. Please wait until a model `cron` interval has elapsed.{next_run_ready_msg}"
)
return CompletionStatus.NOTHING_TO_DO

Expand Down
17 changes: 9 additions & 8 deletions sqlmesh/core/snapshot/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2087,12 +2087,13 @@ def _check_ready_intervals(
return checked_intervals


def get_next_model_interval_start(snapshots: t.Iterable[Snapshot]) -> datetime:
def get_next_model_interval_start(snapshots: t.Iterable[Snapshot]) -> t.Optional[datetime]:
now_dt = now()
return min(
[
snap.node.cron_next(now_dt)
for snap in snapshots
if snap.is_model and not snap.is_symbolic and not snap.is_seed
]
)

starts = [
snap.node.cron_next(now_dt)
for snap in snapshots
if snap.is_model and not snap.is_symbolic and not snap.is_seed
]

return min(starts) if starts else None