Skip to content

Commit 46908a1

Browse files
potiukkaxil
andauthored
Bring back "standard" example dags to the airflow-core package (#51192)
As we are working on a longer-term solution for example-dags, the short-term one is to bring the standard example_dags back to the airflow-core via symbolic link to the standard package folder. This makes the dags to be copied to the airflow-core from the latest main version (but those dags don't change) while not requiring to duplicate the dags and keep them in standard provider where the documentation for them is kept. Co-authored-by: Kaxil Naik <[email protected]>
1 parent a08ea0a commit 46908a1

File tree

5 files changed

+4
-44
lines changed

5 files changed

+4
-44
lines changed

airflow-core/src/airflow/dag_processing/bundles/manager.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# under the License.
1717
from __future__ import annotations
1818

19-
import os
2019
from typing import TYPE_CHECKING
2120

2221
from airflow.configuration import conf
@@ -35,7 +34,6 @@
3534
from airflow.dag_processing.bundles.base import BaseDagBundle
3635

3736
_example_dag_bundle_name = "example_dags"
38-
_example_standard_dag_bundle_name = "example_standard_dags"
3937

4038

4139
def _bundle_item_exc(msg):
@@ -82,25 +80,6 @@ def _add_example_dag_bundle(config_list):
8280
)
8381

8482

85-
def _add_example_standard_dag_bundle(config_list):
86-
# TODO(potiuk): make it more generic - for now we only add standard example_dags if they are locally available
87-
try:
88-
from system import standard
89-
except ImportError:
90-
return
91-
92-
example_dag_folder = next(iter(standard.__path__))
93-
config_list.append(
94-
{
95-
"name": _example_standard_dag_bundle_name,
96-
"classpath": "airflow.dag_processing.bundles.local.LocalDagBundle",
97-
"kwargs": {
98-
"path": example_dag_folder,
99-
},
100-
}
101-
)
102-
103-
10483
class DagBundlesManager(LoggingMixin):
10584
"""Manager for DAG bundles."""
10685

@@ -133,11 +112,6 @@ def parse_config(self) -> None:
133112
_validate_bundle_config(config_list)
134113
if conf.getboolean("core", "LOAD_EXAMPLES"):
135114
_add_example_dag_bundle(config_list)
136-
if (
137-
os.environ.get("BREEZE", "").lower() == "true"
138-
or os.environ.get("_IN_UNIT_TESTS", "").lower() == "true"
139-
):
140-
_add_example_standard_dag_bundle(config_list)
141115

142116
for cfg in config_list:
143117
name = cfg["name"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../providers/standard/tests/system/standard/

airflow-core/src/airflow/models/dagbag.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -598,14 +598,6 @@ def collect_dags(
598598
example_dag_folder = next(iter(example_dags.__path__))
599599

600600
files_to_parse.extend(list_py_file_paths(example_dag_folder, safe_mode=safe_mode))
601-
try:
602-
from system import standard
603-
604-
example_dag_folder_standard = next(iter(standard.__path__))
605-
files_to_parse.extend(list_py_file_paths(example_dag_folder_standard, safe_mode=safe_mode))
606-
except ImportError:
607-
# Nothing happens - this should only work during tests
608-
pass
609601

610602
for filepath in files_to_parse:
611603
try:

airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_report.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
from airflow.utils.file import list_py_file_paths
2525

26-
from tests_common.pytest_plugin import AIRFLOW_ROOT_PATH
2726
from tests_common.test_utils.config import conf_vars
2827
from tests_common.test_utils.db import clear_db_dags, parse_and_sync_to_db
2928

@@ -34,18 +33,12 @@
3433
TEST_DAG_FOLDER_INVALID = "/invalid/path"
3534
TEST_DAG_FOLDER_INVALID_2 = "/root/airflow/tests/dags/"
3635

37-
STANDARD_PROVIDER_SYSTEM_TESTS_PATH = (
38-
AIRFLOW_ROOT_PATH / "providers" / "standard" / "tests" / "system" / "standard"
39-
)
40-
4136

4237
def get_corresponding_dag_file_count(dir: str, include_examples: bool = True) -> int:
4338
from airflow import example_dags
4439

45-
return (
46-
len(list_py_file_paths(directory=dir))
47-
+ (len(list_py_file_paths(next(iter(example_dags.__path__)))) if include_examples else 0)
48-
+ (len(list_py_file_paths(STANDARD_PROVIDER_SYSTEM_TESTS_PATH.as_posix())) if include_examples else 0)
40+
return len(list_py_file_paths(directory=dir)) + (
41+
len(list_py_file_paths(next(iter(example_dags.__path__)))) if include_examples else 0
4942
)
5043

5144

airflow-core/tests/unit/models/test_dagbag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
pytestmark = pytest.mark.db_test
5454

55-
example_dags_folder = AIRFLOW_ROOT_PATH / "providers" / "standard" / "tests" / "system" / "standard"
55+
example_dags_folder = AIRFLOW_ROOT_PATH / "airflow-core" / "src" / "airflow" / "example_dags" / "standard"
5656

5757
PY311 = sys.version_info >= (3, 11)
5858

0 commit comments

Comments
 (0)