File tree Expand file tree Collapse file tree
sqlmesh/schedulers/airflow Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313from sqlmesh .core .environment import Environment , EnvironmentNamingInfo
1414from sqlmesh .core .notification_target import NotificationTarget
1515from sqlmesh .core .plan import PlanStatus
16- from sqlmesh .core .snapshot import Snapshot , SnapshotId , SnapshotTableInfo
16+ from sqlmesh .core .snapshot import (
17+ Snapshot ,
18+ SnapshotId ,
19+ SnapshotIdLike ,
20+ SnapshotTableInfo ,
21+ )
1722from sqlmesh .schedulers .airflow import common , util
1823from sqlmesh .schedulers .airflow .operators import targets
1924from sqlmesh .schedulers .airflow .operators .hwm_sensor import HighWaterMarkSensor
@@ -61,12 +66,13 @@ def __init__(
6166 self ._ddl_engine_operator_args = ddl_engine_operator_args or {}
6267 self ._snapshots = snapshots
6368
64- def generate_cadence_dags (self ) -> t .List [DAG ]:
65- return [
66- self ._create_cadence_dag_for_snapshot (s )
67- for s in self ._snapshots .values ()
68- if s .unpaused_ts and not s .is_symbolic and not s .is_seed
69- ]
69+ def generate_cadence_dags (self , snapshots : t .Iterable [SnapshotIdLike ]) -> t .List [DAG ]:
70+ dags = []
71+ for s in snapshots :
72+ snapshot = self ._snapshots [s .snapshot_id ]
73+ if snapshot .unpaused_ts and not snapshot .is_symbolic and not snapshot .is_seed :
74+ dags .append (self ._create_cadence_dag_for_snapshot (snapshot ))
75+ return dags
7076
7177 def generate_plan_application_dag (self , spec : common .PlanDagSpec ) -> DAG :
7278 return self ._create_plan_application_dag (spec )
Original file line number Diff line number Diff line change 1010from airflow .utils .session import provide_session
1111from sqlalchemy .orm import Session
1212
13+ from sqlmesh .core import constants as c
1314from sqlmesh .engines import commands
1415from sqlmesh .schedulers .airflow import common , util
1516from sqlmesh .schedulers .airflow .dag_generator import SnapshotDagGenerator
@@ -107,7 +108,8 @@ def dags(self) -> t.List[DAG]:
107108 stored_snapshots ,
108109 )
109110
110- cadence_dags = dag_generator .generate_cadence_dags ()
111+ prod_env = state_sync .get_environment (c .PROD )
112+ cadence_dags = dag_generator .generate_cadence_dags (prod_env .snapshots ) if prod_env else []
111113
112114 plan_application_dags = [
113115 dag_generator .generate_plan_application_dag (s ) for s in _get_plan_dag_specs ()
You can’t perform that action at this time.
0 commit comments