Skip to content

Commit

Permalink
Chore: condense completion messages (#3563)
Browse files Browse the repository at this point in the history
  • Loading branch information
treysp authored Jan 6, 2025
1 parent 41a7b4d commit 00143b5
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 68 deletions.
12 changes: 6 additions & 6 deletions sqlmesh/core/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def stop_evaluation_progress(self, success: bool = True) -> None:
if self.evaluation_progress_live:
self.evaluation_progress_live.stop()
if success:
self.log_success("All model batches have been executed successfully")
self.log_success("Model batches executed successfully")

self.evaluation_progress_live = None
self.evaluation_total_progress = None
Expand Down Expand Up @@ -458,7 +458,7 @@ def stop_creation_progress(self, success: bool = True) -> None:
self.creation_progress.stop()
self.creation_progress = None
if success:
self.log_success("All model versions have been created successfully")
self.log_success("Model versions created successfully")

self.environment_naming_info = EnvironmentNamingInfo()
self.default_catalog = None
Expand Down Expand Up @@ -535,7 +535,7 @@ def stop_promotion_progress(self, success: bool = True) -> None:
self.promotion_progress.stop()
self.promotion_progress = None
if success:
self.log_success("The target environment has been updated successfully")
self.log_success("Target environment updated successfully")

self.environment_naming_info = EnvironmentNamingInfo()
self.default_catalog = None
Expand All @@ -561,15 +561,15 @@ def log_migration_status(self, success: bool = True) -> None:
if self.migration_progress is not None:
self.migration_progress = None
if success:
self.log_success("The migration has been completed successfully")
self.log_success("Migration completed successfully")

def stop_snapshot_migration_progress(self, success: bool = True) -> None:
"""Stop the migration progress."""
self.migration_task = None
if self.migration_progress is not None:
self.migration_progress.stop()
if success:
self.log_success("All snapshots have been migrated successfully")
self.log_success("Snapshots migrated successfully")

def start_env_migration_progress(self, total_tasks: int) -> None:
"""Indicates that a new environment migration has begun."""
Expand All @@ -595,7 +595,7 @@ def stop_env_migration_progress(self, success: bool = True) -> None:
self.env_migration_progress.stop()
self.env_migration_progress = None
if success:
self.log_success("All environments have been migrated successfully")
self.log_success("Environments migrated successfully")

def show_model_difference_summary(
self,
Expand Down
6 changes: 3 additions & 3 deletions sqlmesh/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ def _has_environment_changed() -> bool:
done = True
except CircuitBreakerError:
logger.warning(
"Environment '%s' has been modified while running. Restarting the run...",
"Environment '%s' modified while running. Restarting the run...",
environment,
)
if exit_on_env_update:
Expand Down Expand Up @@ -1404,9 +1404,9 @@ def invalidate_environment(self, name: str, sync: bool = False) -> None:
self.state_sync.invalidate_environment(name)
if sync:
self._cleanup_environments()
self.console.log_success(f"Environment '{name}' has been deleted.")
self.console.log_success(f"Environment '{name}' deleted.")
else:
self.console.log_success(f"Environment '{name}' has been invalidated.")
self.console.log_success(f"Environment '{name}' invalidated.")

@python_api_analytics
def diff(self, environment: t.Optional[str] = None, detailed: bool = False) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion sqlmesh/core/plan/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def evaluate(
if not plan_application_succeeded:
raise PlanError("Plan application failed.")

self.console.log_success("The plan has been applied successfully")
self.console.log_success("Plan applied successfully")

@property
def client(self) -> BaseAirflowClient:
Expand Down
2 changes: 1 addition & 1 deletion sqlmesh/utils/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class UnsupportedCatalogOperationError(EngineAdapterError):

class CircuitBreakerError(SQLMeshError):
def __init__(self) -> None:
super().__init__("Circuit breaker has been triggered.")
super().__init__("Circuit breaker triggered.")


def raise_config_error(
Expand Down
105 changes: 53 additions & 52 deletions tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ def assert_new_env(result, new_env="prod", from_env="prod", initialize=True) ->


def assert_model_versions_created(result) -> None:
assert "All model versions have been created successfully" in result.output
assert "Model versions created successfully" in result.output


def assert_model_batches_executed(result) -> None:
assert "All model batches have been executed successfully" in result.output
assert "Model batches executed successfully" in result.output


def assert_target_env_updated(result) -> None:
assert "The target environment has been updated successfully" in result.output
assert "Target environment updated successfully" in result.output


def assert_backfill_success(result) -> None:
Expand Down Expand Up @@ -244,7 +244,7 @@ def test_plan_skip_backfill(runner, tmp_path, flag):
)
assert result.exit_code == 0
assert_virtual_update(result)
assert "All model batches have been executed successfully" not in result.output
assert "Model batches executed successfully" not in result.output


def test_plan_auto_apply(runner, tmp_path):
Expand Down Expand Up @@ -450,8 +450,8 @@ def test_plan_dev_no_prompts(runner, tmp_path):
cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", "dev", "--no-prompts"]
)
assert "Apply - Backfill Tables [y/n]: " in result.output
assert "All model versions have been created successfully" not in result.output
assert "All model batches have been executed successfully" not in result.output
assert "Model versions created successfully" not in result.output
assert "Model batches executed successfully" not in result.output
assert "The target environment has been updated successfully" not in result.output


Expand Down Expand Up @@ -896,50 +896,51 @@ def test_plan_dlt(runner, tmp_path):
assert incremental_model == expected_incremental_model
assert nested_model == expected_nested_fillings_model

# Plan prod and backfill
result = runner.invoke(
cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", "--auto-apply"]
)

assert result.exit_code == 0
assert_backfill_success(result)

# Remove and update with missing model
remove(dlt_waiters_model_path)
assert not dlt_waiters_model_path.exists()

# Update with force = False will generate only the missing model
context = Context(paths=tmp_path)
assert generate_dlt_models(context, "sushi", [], False) == [
"sushi_dataset_sqlmesh.incremental_waiters"
]
assert dlt_waiters_model_path.exists()

# Remove all models
remove(dlt_waiters_model_path)
remove(dlt_loads_model_path)
remove(dlt_sushi_types_model_path)
remove(dlt_sushi_fillings_model_path)
remove(dlt_sushi_twice_nested_model_path)

# Update to generate a specific model: sushi_types
assert generate_dlt_models(context, "sushi", ["sushi_types"], False) == [
"sushi_dataset_sqlmesh.incremental_sushi_types"
]

# Only the sushi_types should be generated now
assert not dlt_waiters_model_path.exists()
assert not dlt_loads_model_path.exists()
assert not dlt_sushi_fillings_model_path.exists()
assert not dlt_sushi_twice_nested_model_path.exists()
assert dlt_sushi_types_model_path.exists()

# Update with force = True will generate all models and overwrite existing ones
generate_dlt_models(context, "sushi", [], True)
assert dlt_loads_model_path.exists()
assert dlt_sushi_types_model_path.exists()
assert dlt_waiters_model_path.exists()
assert dlt_sushi_fillings_model_path.exists()
assert dlt_sushi_twice_nested_model_path.exists()
try:
# Plan prod and backfill
result = runner.invoke(
cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", "--auto-apply"]
)

remove(dataset_path)
assert result.exit_code == 0
assert_backfill_success(result)

# Remove and update with missing model
remove(dlt_waiters_model_path)
assert not dlt_waiters_model_path.exists()

# Update with force = False will generate only the missing model
context = Context(paths=tmp_path)
assert generate_dlt_models(context, "sushi", [], False) == [
"sushi_dataset_sqlmesh.incremental_waiters"
]
assert dlt_waiters_model_path.exists()

# Remove all models
remove(dlt_waiters_model_path)
remove(dlt_loads_model_path)
remove(dlt_sushi_types_model_path)
remove(dlt_sushi_fillings_model_path)
remove(dlt_sushi_twice_nested_model_path)

# Update to generate a specific model: sushi_types
assert generate_dlt_models(context, "sushi", ["sushi_types"], False) == [
"sushi_dataset_sqlmesh.incremental_sushi_types"
]

# Only the sushi_types should be generated now
assert not dlt_waiters_model_path.exists()
assert not dlt_loads_model_path.exists()
assert not dlt_sushi_fillings_model_path.exists()
assert not dlt_sushi_twice_nested_model_path.exists()
assert dlt_sushi_types_model_path.exists()

# Update with force = True will generate all models and overwrite existing ones
generate_dlt_models(context, "sushi", [], True)
assert dlt_loads_model_path.exists()
assert dlt_sushi_types_model_path.exists()
assert dlt_waiters_model_path.exists()
assert dlt_sushi_fillings_model_path.exists()
assert dlt_sushi_twice_nested_model_path.exists()
finally:
remove(dataset_path)
10 changes: 5 additions & 5 deletions tests/integrations/jupyter/test_magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def test_plan(
)
# TODO: Is this what we expect?
assert text_output[2] == ""
assert text_output[3] == "The target environment has been updated successfully"
assert text_output[3] == "Target environment updated successfully"
assert convert_all_html_output_to_tags(output) == [
["pre", "span"],
["pre"] + ["span"] * 4,
Expand All @@ -326,7 +326,7 @@ def test_run_dag(
assert not output.stderr
assert len(output.outputs) == 2
assert convert_all_html_output_to_text(output) == [
"All model batches have been executed successfully",
"Model batches executed successfully",
"Run finished for environment 'prod'",
]
assert get_all_html_output(output) == [
Expand All @@ -337,7 +337,7 @@ def test_run_dag(
h(
"span",
{"style": SUCCESS_STYLE},
"All model batches have been executed successfully",
"Model batches executed successfully",
autoescape=False,
),
autoescape=False,
Expand Down Expand Up @@ -381,7 +381,7 @@ def test_invalidate(
assert not output.stderr
assert len(output.outputs) == 1
assert convert_all_html_output_to_text(output) == [
"Environment 'dev' has been invalidated.",
"Environment 'dev' invalidated.",
]
assert get_all_html_output(output) == [
str(
Expand All @@ -408,7 +408,7 @@ def test_invalidate(
h(
"span",
{"style": SUCCESS_STYLE},
" has been invalidated.",
" invalidated.",
autoescape=False,
)
),
Expand Down

0 comments on commit 00143b5

Please sign in to comment.