|
14 | 14 | import pytest |
15 | 15 | from pytest import MonkeyPatch |
16 | 16 | from pathlib import Path |
17 | | -from sqlmesh.core.console import set_console, get_console, TerminalConsole, CaptureTerminalConsole |
| 17 | +from sqlmesh.core.console import ( |
| 18 | + MarkdownConsole, |
| 19 | + set_console, |
| 20 | + get_console, |
| 21 | + TerminalConsole, |
| 22 | + CaptureTerminalConsole, |
| 23 | +) |
18 | 24 | from sqlmesh.core.config.naming import NameInferenceConfig |
19 | 25 | from sqlmesh.core.model.common import ParsableSql |
20 | 26 | from sqlmesh.utils.concurrency import NodeExecutionFailedError |
@@ -10589,9 +10595,16 @@ def entrypoint(evaluator: MacroEvaluator) -> str: |
10589 | 10595 | new_model_a_snapshot_id = list(plan.modified_snapshots)[0] |
10590 | 10596 |
|
10591 | 10597 | # now, trigger a prod restatement plan in a different thread and block it to simulate a long restatement |
| 10598 | + thread_console = None |
| 10599 | + |
10592 | 10600 | def _run_restatement_plan(tmp_path: Path, config: Config, q: queue.Queue): |
| 10601 | + nonlocal thread_console |
10593 | 10602 | q.put("thread_started") |
10594 | 10603 |
|
| 10604 | + # Give this thread its own markdown console to avoid Rich LiveError |
| 10605 | + thread_console = MarkdownConsole() |
| 10606 | + set_console(thread_console) |
| 10607 | + |
10595 | 10608 | # give this thread its own Context object to prevent segfaulting the Python interpreter |
10596 | 10609 | restatement_ctx = Context(paths=[tmp_path], config=config) |
10597 | 10610 |
|
@@ -10647,7 +10660,7 @@ def _run_restatement_plan(tmp_path: Path, config: Config, q: queue.Queue): |
10647 | 10660 | assert isinstance(plan_error, ConflictingPlanError) |
10648 | 10661 | assert "please re-apply your plan" in repr(plan_error).lower() |
10649 | 10662 |
|
10650 | | - output = " ".join(re.split("\s+", console.captured_output, flags=re.UNICODE)) |
| 10663 | + output = " ".join(re.split("\\s+", thread_console.captured_output, flags=re.UNICODE)) # type: ignore |
10651 | 10664 | assert ( |
10652 | 10665 | f"The following models had new versions deployed while data was being restated: └── test.model_a" |
10653 | 10666 | in output |
|
0 commit comments