Skip to content

Commit eb53d33

Browse files
authored
Run providers compat test with Airflow 3.1 & fix compat (apache#56118)
Some compat layers were wrong! Fixed them while adding 3.1.0 to provider compat matrix
1 parent 043e792 commit eb53d33

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

dev/breeze/src/airflow_breeze/global_constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,12 @@ def generate_provider_dependencies_if_needed():
793793
"remove-providers": "",
794794
"run-unit-tests": "true",
795795
},
796+
{
797+
"python-version": "3.10",
798+
"airflow-version": "3.1.0",
799+
"remove-providers": "",
800+
"run-unit-tests": "true",
801+
},
796802
]
797803

798804
ALL_PYTHON_VERSION_TO_PATCHLEVEL_VERSION: dict[str, str] = {

devel-common/src/tests_common/pytest_plugin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,10 @@ def run_ti(self, task_id, dag_run=None, dag_run_kwargs=None, map_index=-1, **kwa
11751175

11761176
def sync_dagbag_to_db(self):
11771177
if AIRFLOW_V_3_1_PLUS:
1178-
from airflow.dag_processing.dagbag import sync_bag_to_db
1178+
try:
1179+
from airflow.dag_processing.dagbag import sync_bag_to_db
1180+
except ImportError:
1181+
from airflow.models.dagbag import sync_bag_to_db
11791182

11801183
sync_bag_to_db(self.dagbag, self.bundle_name, None)
11811184
elif AIRFLOW_V_3_0_PLUS:

devel-common/src/tests_common/test_utils/db.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,11 @@ def _bootstrap_dagbag():
105105

106106
dagbag = DagBag()
107107
# Save DAGs in the ORM
108-
if AIRFLOW_V_3_2_PLUS:
109-
from airflow.dag_processing.dagbag import sync_bag_to_db
108+
if AIRFLOW_V_3_1_PLUS:
109+
try:
110+
from airflow.dag_processing.dagbag import sync_bag_to_db
111+
except ImportError:
112+
from airflow.models.dagbag import sync_bag_to_db
110113

111114
sync_bag_to_db(dagbag, bundle_name="dags-folder", bundle_version=None, session=session)
112115
elif AIRFLOW_V_3_0_PLUS:
@@ -180,8 +183,11 @@ def parse_and_sync_to_db(folder: Path | str, include_examples: bool = False):
180183
session.flush()
181184

182185
dagbag = DagBag(dag_folder=folder, include_examples=include_examples)
183-
if AIRFLOW_V_3_2_PLUS:
184-
from airflow.dag_processing.dagbag import sync_bag_to_db
186+
if AIRFLOW_V_3_1_PLUS:
187+
try:
188+
from airflow.dag_processing.dagbag import sync_bag_to_db
189+
except ImportError:
190+
from airflow.models.dagbag import sync_bag_to_db # type: ignore[no-redef, attribute-defined]
185191

186192
sync_bag_to_db(dagbag, "dags-folder", None, session=session)
187193
elif AIRFLOW_V_3_0_PLUS:

0 commit comments

Comments
 (0)