Skip to content

Commit b7ec392

Browse files
committed
Move filtering into console method
1 parent 4f06133 commit b7ec392

5 files changed

Lines changed: 17 additions & 15 deletions

File tree

sqlmesh/core/console.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -968,10 +968,13 @@ def start_promotion_progress(
968968
"Updating virtual layer ", self.console, justify="left"
969969
)
970970

971+
snapshots_with_virtual_views = [
972+
s for s in snapshots if s.is_model and not s.is_symbolic
973+
]
971974
self.promotion_progress.start()
972975
self.promotion_task = self.promotion_progress.add_task(
973976
f"Virtually updating {environment_naming_info.name}...",
974-
total=len(snapshots),
977+
total=len(snapshots_with_virtual_views),
975978
)
976979

977980
# determine name column widths if we're printing names
@@ -984,15 +987,20 @@ def start_promotion_progress(
984987
dialect=self.dialect,
985988
)
986989
)
987-
for snapshot in snapshots
990+
for snapshot in snapshots_with_virtual_views
988991
)
989992

990993
self.environment_naming_info = environment_naming_info
991994
self.default_catalog = default_catalog
992995

993996
def update_promotion_progress(self, snapshot: SnapshotInfoLike, promoted: bool) -> None:
994997
"""Update the snapshot promotion progress."""
995-
if self.promotion_progress is not None and self.promotion_task is not None:
998+
if (
999+
self.promotion_progress is not None
1000+
and self.promotion_task is not None
1001+
and snapshot.is_model
1002+
and not snapshot.is_symbolic
1003+
):
9961004
if self.verbosity >= Verbosity.VERBOSE:
9971005
display_name = snapshot.display_name(
9981006
self.environment_naming_info,
@@ -1007,9 +1015,7 @@ def update_promotion_progress(self, snapshot: SnapshotInfoLike, promoted: bool)
10071015
else "[green]created[/green]"
10081016
)
10091017
action_str = action_str or "[red]dropped[/red]"
1010-
self.promotion_progress.live.console.print(
1011-
f"{snapshot.display_name(self.environment_naming_info, self.default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect).ljust(self.PROGRESS_BAR_COLUMN_WIDTHS['name'])} {action_str.ljust(7)}"
1012-
)
1018+
self.promotion_progress.live.console.print(f"{display_name} {action_str}")
10131019
self.promotion_progress.update(self.promotion_task, refresh=True, advance=1)
10141020

10151021
def stop_promotion_progress(self, success: bool = True) -> None:

sqlmesh/core/plan/evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def _update_views(
376376
environment = plan.environment
377377

378378
self.console.start_promotion_progress(
379-
len(promotion_result.added) + len(promotion_result.removed),
379+
promotion_result.added + promotion_result.removed,
380380
environment.naming_info,
381381
self.default_catalog,
382382
)

sqlmesh/core/scheduler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def run_merged_intervals(
427427
batched_intervals = self.batch_intervals(merged_intervals, deployability_index)
428428

429429
self.console.start_evaluation_progress(
430-
{snapshot: len(intervals) for snapshot, intervals in batched_intervals.items()},
430+
batched_intervals,
431431
environment_naming_info,
432432
self.default_catalog,
433433
)

tests/cli/test_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ def test_plan_verbose(runner, tmp_path):
294294
cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", "--verbose"], input="y\n"
295295
)
296296
assert_plan_success(result)
297-
assert "sqlmesh_example.seed_model created" in result.output
298-
assert "sqlmesh_example.full_model created" in result.output
297+
assert "sqlmesh_example.seed_model created" in result.output
298+
assert "sqlmesh_example.full_model created" in result.output
299299

300300

301301
def test_plan_very_verbose(runner, tmp_path, copy_to_temp_path):

web/server/console.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,7 @@ def start_promotion_progress(
172172

173173
self.log_event_plan_apply()
174174

175-
def update_promotion_progress(
176-
self,
177-
snapshot: SnapshotInfoLike,
178-
promoted: bool,
179-
) -> None:
175+
def update_promotion_progress(self, snapshot: SnapshotInfoLike, promoted: bool) -> None:
180176
if self.plan_apply_stage_tracker and self.plan_apply_stage_tracker.promote:
181177
self.plan_apply_stage_tracker.promote.update(
182178
{"num_tasks": self.plan_apply_stage_tracker.promote.num_tasks + 1}

0 commit comments

Comments
 (0)