Skip to content

Commit 6d65e6b

Browse files
authored
Fix: In Airflow skip state migration when loading the SQLMesh plugin on the Webserver instance (#1565)
1 parent fad0c60 commit 6d65e6b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

sqlmesh/schedulers/airflow/plugin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import logging
4+
import os
45
import time
56
import typing as t
67

@@ -19,8 +20,14 @@ class SqlmeshAirflowPlugin(AirflowPlugin):
1920

2021
@classmethod
2122
def on_load(cls, *args: t.Any, **kwargs: t.Any) -> None:
23+
if os.environ.get("MWAA_AIRFLOW_COMPONENT", "").lower() == "webserver":
24+
# When using MWAA, the Webserver instance might not have access to the external state database.
25+
logger.info("MWAA Webserver instance detected. Skipping SQLMesh state migration...")
26+
return
27+
2228
with util.scoped_state_sync() as state_sync:
2329
try:
30+
logger.info("Migrating SQLMesh state ...")
2431
state_sync.migrate()
2532
except Exception as ex:
2633
# This method is called once for each Gunicorn worker spawned by the Airflow Webserver,

0 commit comments

Comments
 (0)