Repository: TobikoData/sqlmesh
Pull request #2374 (2024-04-01 16:20:35)

Chore: Report success at the end of the run command


Patch:
diff --git a/sqlmesh/core/context.py b/sqlmesh/core/context.py
index c012f66d..c45716ca 100644
--- a/sqlmesh/core/context.py
+++ b/sqlmesh/core/context.py
@@ -518,6 +518,7 @@ class GenericContext(BaseContext, t.Generic[C]):
             self.notification_target_manager.notify(
                 NotificationEvent.RUN_END, environment=environment
             )
+            self.console.log_success(f"Run finished for environment '{environment}'")
         else:
             self.notification_target_manager.notify(
                 NotificationEvent.RUN_FAILURE, "See console logs for details."
diff --git a/web/server/watcher.py b/web/server/watcher.py
index 85ec364f..dbe6c7f6 100644
--- a/web/server/watcher.py
+++ b/web/server/watcher.py
@@ -83,7 +83,14 @@ async def watch_project() -> None:
                 ).to_dict()
                 api_console.log_event(event=models.EventName.WARNINGS, data=error)
 
-        if settings.modules.intersection({models.Modules.FILES, models.Modules.DOCS}):
+        if settings.modules.intersection(
+            {
+                models.Modules.FILES,
+                models.Modules.DOCS,
+                models.Modules.PLANS,
+                models.Modules.LINEAGE,
+            }
+        ):
             api_console.log_event(
                 event=models.EventName.FILE,
                 data={"changes": changes, "directories": directories},


Test patch:
diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py
index d388d721..c3c3abec 100644
--- a/tests/cli/test_cli.py
+++ b/tests/cli/test_cli.py
@@ -588,7 +588,7 @@ def test_run_cron_not_elapsed(runner, tmp_path, caplog):
     with disable_logging():
         result = runner.invoke(cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "run"])
     assert result.exit_code == 0
-    assert result.output.strip() == ""
+    assert result.output.strip() == "Run finished for environment 'prod'"
 
 
 def test_run_cron_elapsed(runner, tmp_path):
diff --git a/tests/integrations/jupyter/test_magics.py b/tests/integrations/jupyter/test_magics.py
index d2f33aae..c98f4827 100644
--- a/tests/integrations/jupyter/test_magics.py
+++ b/tests/integrations/jupyter/test_magics.py
@@ -345,9 +345,10 @@ def test_run_dag(
         "'Evaluating models ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 18/18"
     )
     assert not output.stderr
-    assert len(output.outputs) == 1
+    assert len(output.outputs) == 2
     assert convert_all_html_output_to_text(output) == [
         "All model batches have been executed successfully",
+        "Run finished for environment 'prod'",
     ]
     assert get_all_html_output(output) == [
         str(
@@ -360,7 +361,23 @@ def test_run_dag(
                     "All model batches have been executed successfully",
                 ),
             )
-        )
+        ),
+        str(
+            h(
+                "pre",
+                {"style": RICH_PRE_STYLE},
+                h(
+                    "span",
+                    {"style": SUCCESS_STYLE},
+                    "Run finished for environment ",
+                ),
+                h(
+                    "span",
+                    {"style": SUCCESS_STYLE},
+                    "'prod'",
+                ),
+            )
+        ),
     ]