Skip to content

Commit ba54aa8

Browse files
committed
PR feedback
1 parent c015f88 commit ba54aa8

File tree

3 files changed

+11
-27
lines changed

3 files changed

+11
-27
lines changed

sqlmesh/core/console.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -498,13 +498,9 @@ def stop_env_migration_progress(self, success: bool = True) -> None:
498498
"""Stop the environment migration progress."""
499499

500500
@abc.abstractmethod
501-
def log_pre_check_warnings(
502-
self,
503-
pre_check_warnings: t.List[t.Tuple[str, t.List[str]]],
504-
pre_check_only: bool,
505-
) -> bool:
501+
def log_pre_check_warnings(self, pre_check_warnings: t.List[str], pre_check_only: bool) -> bool:
506502
"""
507-
Log warnings emitted by pre-check scripts and ask user whether they'd like to
503+
Log warnings emitted by pre-checks and ask user whether they'd like to
508504
proceed with the migration (true) or not (false).
509505
"""
510506

@@ -673,11 +669,7 @@ def update_env_migration_progress(self, num_tasks: int) -> None:
673669
def stop_env_migration_progress(self, success: bool = True) -> None:
674670
pass
675671

676-
def log_pre_check_warnings(
677-
self,
678-
pre_check_warnings: t.List[t.Tuple[str, t.List[str]]],
679-
pre_check_only: bool,
680-
) -> bool:
672+
def log_pre_check_warnings(self, pre_check_warnings: t.List[str], pre_check_only: bool) -> bool:
681673
return True
682674

683675
def start_state_export(
@@ -1490,16 +1482,11 @@ def stop_env_migration_progress(self, success: bool = True) -> None:
14901482
if success:
14911483
self.log_success("Environments migrated successfully")
14921484

1493-
def log_pre_check_warnings(
1494-
self,
1495-
pre_check_warnings: t.List[t.Tuple[str, t.List[str]]],
1496-
pre_check_only: bool,
1497-
) -> bool:
1485+
def log_pre_check_warnings(self, pre_check_warnings: t.List[str], pre_check_only: bool) -> bool:
14981486
if pre_check_warnings:
1499-
for pre_check, warnings in pre_check_warnings:
1500-
tree = Tree(f"[bold]Pre-migration warnings for {pre_check}[/bold]")
1501-
for warning in warnings:
1502-
tree.add(f"[yellow]{warning}[/yellow]")
1487+
tree = Tree(f"[bold]Pre-migration warnings[/bold]")
1488+
for warning in pre_check_warnings:
1489+
tree.add(f"[yellow]{warning}[/yellow]")
15031490

15041491
self._print(tree)
15051492

sqlmesh/core/state_sync/db/migrator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def rollback(self) -> None:
165165

166166
logger.info("Migration rollback successful.")
167167

168-
def _run_pre_checks(self, state_sync: StateSync) -> t.List[t.Tuple[str, t.List[str]]]:
168+
def _run_pre_checks(self, state_sync: StateSync) -> t.List[str]:
169169
"""Run pre-checks for migrations between specified versions.
170170
171171
Args:
@@ -185,7 +185,7 @@ def _run_pre_checks(self, state_sync: StateSync) -> t.List[t.Tuple[str, t.List[s
185185
logger.info(f"Running pre-check for {migration_name}")
186186
warnings = pre_check(state_sync)
187187
if warnings:
188-
pre_check_warnings.append((migration_name, warnings))
188+
pre_check_warnings.extend(warnings)
189189

190190
return pre_check_warnings
191191

tests/core/state_sync/test_state_sync.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3691,11 +3691,8 @@ def mock_pre_check_without_warnings(state_sync):
36913691
assert len(calls) == 1
36923692

36933693
pre_check_warnings = calls[0].args[0]
3694-
assert len(pre_check_warnings) == 1
3695-
3696-
assert pre_check_warnings[0][0] == "v9999_test_pre_check"
3697-
assert len(pre_check_warnings[0][1]) == 3
3698-
assert all(warning.startswith("Warning:") for warning in pre_check_warnings[0][1])
3694+
assert len(pre_check_warnings) == 3
3695+
assert all(warning.startswith("Warning:") for warning in pre_check_warnings)
36993696

37003697
assert context.state_sync.get_versions() == versions_before_migrate
37013698

0 commit comments

Comments
 (0)