Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sqlmesh/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,8 @@ def run(
Returns:
True if the run was successful, False otherwise.
"""
self._load_materializations()

environment = environment or self.config.default_target_environment
environment = Environment.sanitize_name(environment)
if not skip_janitor and environment.lower() == c.PROD:
Expand All @@ -793,7 +795,6 @@ def run(
engine_type=self.snapshot_evaluator.adapter.dialect,
state_sync_type=self.state_sync.state_type(),
)
self._load_materializations()

env_check_attempts_num = max(
1,
Expand Down Expand Up @@ -885,6 +886,8 @@ def _has_environment_changed() -> bool:

@python_api_analytics
def run_janitor(self, ignore_ttl: bool) -> bool:
self._load_materializations()

success = False

if self.console.start_cleanup(ignore_ttl):
Expand Down Expand Up @@ -2873,6 +2876,8 @@ def _destroy(self) -> bool:
self.state_sync.invalidate_environment(name=environment.name, protect_prod=False)
self.console.log_success(f"Environment '{environment.name}' invalidated.")

self._load_materializations()

# Run janitor to clean up all objects
self._run_janitor(ignore_ttl=True)

Expand Down