Skip to content
Draft
Show file tree
Hide file tree
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
14 changes: 12 additions & 2 deletions pkg/airflowrt/include/airflow3/dagexampletest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Example DAGs test. This test ensures that all Dags have tags, retries set to two, and no import errors. This is an example pytest and may not be fit the context of your DAGs. Feel free to add and remove tests."""

import os
import inspect
import logging
from contextlib import contextmanager
import pytest
Expand All @@ -18,12 +19,21 @@ def suppress_logging(namespace):
logger.disabled = old_value


def new_dag_bag():
# Airflow 3.3 removed DagBag's `include_examples`; only pass it where supported.
try:
supports_examples = "include_examples" in inspect.signature(DagBag.__init__).parameters
except (ValueError, TypeError):
supports_examples = False
return DagBag(include_examples=False) if supports_examples else DagBag()


def get_import_errors():
"""
Generate a tuple for import errors in the dag bag
"""
with suppress_logging("airflow"):
dag_bag = DagBag(include_examples=False)
dag_bag = new_dag_bag()

def strip_path_prefix(path):
return os.path.relpath(path, os.environ.get("AIRFLOW_HOME"))
Expand All @@ -39,7 +49,7 @@ def get_dags():
Generate a tuple of dag_id, <DAG objects> in the DagBag
"""
with suppress_logging("airflow"):
dag_bag = DagBag(include_examples=False)
dag_bag = new_dag_bag()

def strip_path_prefix(path):
return os.path.relpath(path, os.environ.get("AIRFLOW_HOME"))
Expand Down
12 changes: 11 additions & 1 deletion pkg/airflowrt/include/airflow3/dagintegritytestdefault.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test the validity of all DAGs. **USED BY DEV PARSE COMMAND DO NOT EDIT**"""

from contextlib import contextmanager
import inspect
import logging
import os

Expand Down Expand Up @@ -112,12 +113,21 @@ def suppress_logging(namespace):
logger.disabled = old_value


def new_dag_bag():
# Airflow 3.3 removed DagBag's `include_examples`; only pass it where supported.
try:
supports_examples = "include_examples" in inspect.signature(DagBag.__init__).parameters
except (ValueError, TypeError):
supports_examples = False
return DagBag(include_examples=False) if supports_examples else DagBag()


def get_import_errors():
"""
Generate a tuple for import errors in the dag bag, and include DAGs without errors.
"""
with suppress_logging("airflow"):
dag_bag = DagBag(include_examples=False)
dag_bag = new_dag_bag()

def strip_path_prefix(path):
return os.path.relpath(path, os.environ.get("AIRFLOW_HOME"))
Expand Down
Loading