Skip to content

Commit 9db31c4

Browse files
committed
Base eval progress bar column widths on what will be displayed
1 parent 1bc4661 commit 9db31c4

7 files changed

Lines changed: 175 additions & 124 deletions

File tree

sqlmesh/core/console.py

Lines changed: 138 additions & 98 deletions
Large diffs are not rendered by default.

sqlmesh/core/plan/evaluator.py

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

375375
self.console.start_promotion_progress(
376-
len(promotion_result.added) + len(promotion_result.removed),
376+
promotion_result.added + promotion_result.removed,
377377
environment.naming_info,
378378
self.default_catalog,
379379
)

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
)

sqlmesh/core/snapshot/evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def _get_data_objects(
371371
if not snapshots_to_create:
372372
return CompletionStatus.NOTHING_TO_DO
373373
if on_start:
374-
on_start(len(snapshots_to_create))
374+
on_start(snapshots_to_create)
375375

376376
for gateway, tables_by_schema in tables_by_gateway_and_schema.items():
377377
self._create_schemas(tables=tables_by_schema, gateway=gateway)

sqlmesh/utils/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,18 @@ class Verbosity(IntEnum):
347347
VERBOSE = 1
348348
VERY_VERBOSE = 2
349349

350+
@property
351+
def is_default(self) -> bool:
352+
return self == Verbosity.DEFAULT
353+
354+
@property
355+
def is_verbose(self) -> bool:
356+
return self == Verbosity.VERBOSE
357+
358+
@property
359+
def is_very_verbose(self) -> bool:
360+
return self == Verbosity.VERY_VERBOSE
361+
350362

351363
class CompletionStatus(Enum):
352364
SUCCESS = "success"

tests/cli/test_cli.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,7 @@ def test_plan(runner, tmp_path):
182182
assert_plan_success(result)
183183
# 'Models needing backfill' section and eval progress bar should display the same inclusive intervals
184184
assert "sqlmesh_example.incremental_model: [2020-01-01 - 2022-12-31]" in result.output
185-
assert (
186-
"sqlmesh_example.incremental_model [insert 2020-01-01 -\n2022-12-31]"
187-
in result.output
188-
)
185+
assert "sqlmesh_example.incremental_model [insert 2020-01-01 - 2022-12-31]" in result.output
189186

190187

191188
def test_plan_skip_tests(runner, tmp_path):
@@ -246,7 +243,7 @@ def test_plan_restate_model(runner, tmp_path):
246243
assert result.exit_code == 0
247244
assert_duckdb_test(result)
248245
assert "No changes to plan: project files match the `prod` environment" in result.output
249-
assert "sqlmesh_example.full_model [full refresh" in result.output
246+
assert "sqlmesh_example.full_model [full refresh" in result.output
250247
assert_model_batches_executed(result)
251248
assert_virtual_layer_updated(result)
252249

@@ -297,8 +294,8 @@ def test_plan_verbose(runner, tmp_path):
297294
cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", "--verbose"], input="y\n"
298295
)
299296
assert_plan_success(result)
300-
assert "sqlmesh_example.seed_model created" in result.output
301-
assert "sqlmesh_example.seed_model promoted" in result.output
297+
assert "sqlmesh_example.seed_model created" in result.output
298+
assert "sqlmesh_example.seed_model promoted" in result.output
302299

303300

304301
def test_plan_very_verbose(runner, tmp_path, copy_to_temp_path):
@@ -556,8 +553,8 @@ def test_plan_nonbreaking(runner, tmp_path):
556553
assert "+ 'a' AS new_col" in result.output
557554
assert "Directly Modified: sqlmesh_example.incremental_model (Non-breaking)" in result.output
558555
assert "sqlmesh_example.full_model (Indirect Non-breaking)" in result.output
559-
assert "sqlmesh_example.incremental_model [insert" in result.output
560-
assert "sqlmesh_example.full_model evaluated [full refresh" not in result.output
556+
assert "sqlmesh_example.incremental_model [insert" in result.output
557+
assert "sqlmesh_example.full_model [full refresh" not in result.output
561558
assert_backfill_success(result)
562559

563560

@@ -614,8 +611,8 @@ def test_plan_breaking(runner, tmp_path):
614611
assert result.exit_code == 0
615612
assert "+ item_id + 1 AS item_id," in result.output
616613
assert "Directly Modified: sqlmesh_example.full_model (Breaking)" in result.output
617-
assert "sqlmesh_example.full_model [full refresh" in result.output
618-
assert "sqlmesh_example.incremental_model [insert" not in result.output
614+
assert "sqlmesh_example.full_model [full refresh" in result.output
615+
assert "sqlmesh_example.incremental_model [insert" not in result.output
619616
assert_backfill_success(result)
620617

621618

@@ -653,8 +650,8 @@ def test_plan_dev_select(runner, tmp_path):
653650
assert "+ item_id + 1 AS item_id," not in result.output
654651
assert "Directly Modified: sqlmesh_example__dev.full_model (Breaking)" not in result.output
655652
# only incremental_model backfilled
656-
assert "sqlmesh_example__dev.incremental_model [insert" in result.output
657-
assert "sqlmesh_example__dev.full_model [full refresh" not in result.output
653+
assert "sqlmesh_example__dev.incremental_model [insert" in result.output
654+
assert "sqlmesh_example__dev.full_model [full refresh" not in result.output
658655
assert_backfill_success(result)
659656

660657

@@ -692,8 +689,8 @@ def test_plan_dev_backfill(runner, tmp_path):
692689
"Directly Modified: sqlmesh_example__dev.incremental_model (Non-breaking)" in result.output
693690
)
694691
# only incremental_model backfilled
695-
assert "sqlmesh_example__dev.incremental_model [insert" in result.output
696-
assert "sqlmesh_example__dev.full_model [full refresh" not in result.output
692+
assert "sqlmesh_example__dev.incremental_model [insert" in result.output
693+
assert "sqlmesh_example__dev.full_model [full refresh" not in result.output
697694
assert_backfill_success(result)
698695

699696

web/server/console.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
import json
55
import typing as t
66
import unittest
7-
87
from fastapi.encoders import jsonable_encoder
98
from sse_starlette.sse import ServerSentEvent
10-
from sqlmesh.core.snapshot.definition import Interval
9+
from sqlmesh.core.snapshot.definition import Interval, Intervals
1110
from sqlmesh.core.console import TerminalConsole
1211
from sqlmesh.core.environment import EnvironmentNamingInfo
1312
from sqlmesh.core.plan.definition import EvaluatablePlan
14-
from sqlmesh.core.snapshot import Snapshot, SnapshotInfoLike
13+
from sqlmesh.core.snapshot import Snapshot, SnapshotInfoLike, SnapshotTableInfo
1514
from sqlmesh.core.test import ModelTest
1615
from sqlmesh.utils.date import now_timestamp
1716
from web.server import models
@@ -41,14 +40,14 @@ def stop_plan_evaluation(self) -> None:
4140

4241
def start_creation_progress(
4342
self,
44-
total_tasks: int,
43+
snapshots: t.List[Snapshot],
4544
environment_naming_info: EnvironmentNamingInfo,
4645
default_catalog: t.Optional[str],
4746
) -> None:
4847
if self.plan_apply_stage_tracker:
4948
self.plan_apply_stage_tracker.add_stage(
5049
models.PlanStage.creation,
51-
models.PlanStageCreation(total_tasks=total_tasks, num_tasks=0),
50+
models.PlanStageCreation(total_tasks=len(snapshots), num_tasks=0),
5251
)
5352

5453
self.log_event_plan_apply()
@@ -91,11 +90,14 @@ def stop_restate_progress(self, success: bool) -> None:
9190

9291
def start_evaluation_progress(
9392
self,
94-
batch_sizes: t.Dict[Snapshot, int],
93+
batched_intervals: t.Dict[Snapshot, Intervals],
9594
environment_naming_info: EnvironmentNamingInfo,
9695
default_catalog: t.Optional[str],
9796
) -> None:
9897
if self.plan_apply_stage_tracker:
98+
batch_sizes = {
99+
snapshot: len(intervals) for snapshot, intervals in batched_intervals.items()
100+
}
99101
tasks = {
100102
snapshot.name: models.BackfillTask(
101103
completed=0,
@@ -154,15 +156,15 @@ def stop_evaluation_progress(self, success: bool = True) -> None:
154156

155157
def start_promotion_progress(
156158
self,
157-
total_tasks: int,
159+
snapshots: t.List[SnapshotTableInfo],
158160
environment_naming_info: EnvironmentNamingInfo,
159161
default_catalog: t.Optional[str],
160162
) -> None:
161163
if self.plan_apply_stage_tracker:
162164
self.plan_apply_stage_tracker.add_stage(
163165
models.PlanStage.promote,
164166
models.PlanStagePromote(
165-
total_tasks=total_tasks,
167+
total_tasks=len(snapshots),
166168
num_tasks=0,
167169
target_environment=environment_naming_info.name,
168170
),

0 commit comments

Comments
 (0)