diff --git a/airflow/config_templates/config.yml b/airflow/config_templates/config.yml index 5890e43de6c87..55d4a9fbeb245 100644 --- a/airflow/config_templates/config.yml +++ b/airflow/config_templates/config.yml @@ -2707,7 +2707,7 @@ dag_bundles: [ {{ "name": "dags-folder", - "classpath": "airflow.dag_processing.bundles.dagfolder.DagsFolderDagBundle", + "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", "kwargs": {{}} }} ] diff --git a/airflow/dag_processing/bundles/dagfolder.py b/airflow/dag_processing/bundles/dagfolder.py deleted file mode 100644 index 61b35bc3a1f7e..0000000000000 --- a/airflow/dag_processing/bundles/dagfolder.py +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from __future__ import annotations - -from airflow import settings -from airflow.dag_processing.bundles.local import LocalDagBundle - - -class DagsFolderDagBundle(LocalDagBundle): - """A bundle for the DAGs folder.""" - - def __init__(self, **kwargs): - super().__init__( - local_folder=settings.DAGS_FOLDER, - **kwargs, - ) diff --git a/airflow/dag_processing/bundles/local.py b/airflow/dag_processing/bundles/local.py index 94369934184ad..918e5cd189e30 100644 --- a/airflow/dag_processing/bundles/local.py +++ b/airflow/dag_processing/bundles/local.py @@ -19,6 +19,7 @@ from pathlib import Path +from airflow import settings from airflow.dag_processing.bundles.base import BaseDagBundle @@ -26,14 +27,17 @@ class LocalDagBundle(BaseDagBundle): """ Local DAG bundle - exposes a local directory as a DAG bundle. - :param local_folder: Local folder where the DAGs are stored + :param path: Local path where the DAGs are stored """ supports_versioning = False - def __init__(self, *, local_folder: str, **kwargs) -> None: + def __init__(self, *, path: str | None = None, **kwargs) -> None: super().__init__(**kwargs) - self._path = Path(local_folder) + if path is None: + path = settings.DAGS_FOLDER + + self._path = Path(path) def get_current_version(self) -> None: return None diff --git a/airflow/dag_processing/bundles/manager.py b/airflow/dag_processing/bundles/manager.py index 6729732de4c9c..c5a2115b24f75 100644 --- a/airflow/dag_processing/bundles/manager.py +++ b/airflow/dag_processing/bundles/manager.py @@ -81,7 +81,7 @@ def parse_config(self) -> None: "name": "example_dags", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", "kwargs": { - "local_folder": example_dag_folder, + "path": example_dag_folder, }, } ) diff --git a/providers/tests/fab/auth_manager/conftest.py b/providers/tests/fab/auth_manager/conftest.py index ad23c1e1febb0..9c61f7ab2dccc 100644 --- a/providers/tests/fab/auth_manager/conftest.py +++ b/providers/tests/fab/auth_manager/conftest.py @@ -92,7 +92,7 @@ def _config_bundle(path_to_parse: Path | str): { "name": "testing", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", - "kwargs": {"local_folder": str(path_to_parse), "refresh_interval": 0}, + "kwargs": {"path": str(path_to_parse), "refresh_interval": 0}, } ] with conf_vars({("dag_bundles", "backends"): json.dumps(bundle_config)}): diff --git a/task_sdk/tests/execution_time/test_supervisor.py b/task_sdk/tests/execution_time/test_supervisor.py index 12c3455ccfe1e..fb84713216625 100644 --- a/task_sdk/tests/execution_time/test_supervisor.py +++ b/task_sdk/tests/execution_time/test_supervisor.py @@ -79,7 +79,7 @@ def local_dag_bundle_cfg(path, name="my-bundle"): { "name": name, "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", - "kwargs": {"local_folder": str(path), "refresh_interval": 1}, + "kwargs": {"path": str(path), "refresh_interval": 1}, } ] ) diff --git a/task_sdk/tests/execution_time/test_task_runner.py b/task_sdk/tests/execution_time/test_task_runner.py index f716317ad24fc..0e3698050b88e 100644 --- a/task_sdk/tests/execution_time/test_task_runner.py +++ b/task_sdk/tests/execution_time/test_task_runner.py @@ -135,7 +135,7 @@ def test_parse(test_dags_dir: Path, make_ti_context): { "name": "my-bundle", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", - "kwargs": {"local_folder": str(test_dags_dir), "refresh_interval": 1}, + "kwargs": {"path": str(test_dags_dir), "refresh_interval": 1}, } ] ), @@ -569,7 +569,7 @@ def test_dag_parsing_context(make_ti_context, mock_supervisor_comms, monkeypatch { "name": "my-bundle", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", - "kwargs": {"local_folder": str(test_dags_dir), "refresh_interval": 1}, + "kwargs": {"path": str(test_dags_dir), "refresh_interval": 1}, } ] ) diff --git a/tests/conftest.py b/tests/conftest.py index 8e41e35e35d06..fca82aee34b87 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -108,7 +108,7 @@ def _config_bundle(path_to_parse: Path | str): { "name": "testing", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", - "kwargs": {"local_folder": str(path_to_parse), "refresh_interval": 0}, + "kwargs": {"path": str(path_to_parse), "refresh_interval": 0}, } ] with conf_vars({("dag_bundles", "backends"): json.dumps(bundle_config)}): diff --git a/tests/dag_processing/bundles/test_dag_bundle_manager.py b/tests/dag_processing/bundles/test_dag_bundle_manager.py index 35cecdace6c1f..b0baa21c6f84c 100644 --- a/tests/dag_processing/bundles/test_dag_bundle_manager.py +++ b/tests/dag_processing/bundles/test_dag_bundle_manager.py @@ -50,7 +50,7 @@ { "name": "my-bundle", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", - "kwargs": {"local_folder": "/tmp/hihi", "refresh_interval": 1}, + "kwargs": {"path": "/tmp/hihi", "refresh_interval": 1}, } ] ), diff --git a/tests/dag_processing/test_dag_bundles.py b/tests/dag_processing/test_dag_bundles.py index 1c950f18431c8..32b2277b68c54 100644 --- a/tests/dag_processing/test_dag_bundles.py +++ b/tests/dag_processing/test_dag_bundles.py @@ -25,7 +25,6 @@ from git import Repo from airflow.dag_processing.bundles.base import BaseDagBundle -from airflow.dag_processing.bundles.dagfolder import DagsFolderDagBundle from airflow.dag_processing.bundles.git import GitDagBundle, GitHook from airflow.dag_processing.bundles.local import LocalDagBundle from airflow.exceptions import AirflowException @@ -46,7 +45,7 @@ def bundle_temp_dir(tmp_path): def test_default_dag_storage_path(): with conf_vars({("core", "dag_bundle_storage_path"): ""}): - bundle = LocalDagBundle(name="test", local_folder="/hello") + bundle = LocalDagBundle(name="test", path="/hello") assert bundle._dag_bundle_root_storage_path == Path(tempfile.gettempdir(), "airflow", "dag_bundles") @@ -68,24 +67,22 @@ def path(self): class TestLocalDagBundle: def test_path(self): - bundle = LocalDagBundle(name="test", local_folder="/hello") + bundle = LocalDagBundle(name="test", path="/hello") assert bundle.path == Path("/hello") + @conf_vars({("core", "dags_folder"): "/tmp/somewhere/dags"}) + def test_path_default(self): + bundle = LocalDagBundle(name="test", refresh_interval=300) + assert bundle.path == Path("/tmp/somewhere/dags") + def test_none_for_version(self): assert LocalDagBundle.supports_versioning is False - bundle = LocalDagBundle(name="test", local_folder="/hello") + bundle = LocalDagBundle(name="test", path="/hello") assert bundle.get_current_version() is None -class TestDagsFolderDagBundle: - @conf_vars({("core", "dags_folder"): "/tmp/somewhere/dags"}) - def test_path(self): - bundle = DagsFolderDagBundle(name="test") - assert bundle.path == Path("/tmp/somewhere/dags") - - GIT_DEFAULT_BRANCH = "main" diff --git a/tests/dag_processing/test_manager.py b/tests/dag_processing/test_manager.py index 42e975127797b..4ab55c24eefc0 100644 --- a/tests/dag_processing/test_manager.py +++ b/tests/dag_processing/test_manager.py @@ -839,12 +839,12 @@ def test_bundles_are_refreshed(self): { "name": "bundleone", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", - "kwargs": {"local_folder": "/dev/null", "refresh_interval": 0}, + "kwargs": {"path": "/dev/null", "refresh_interval": 0}, }, { "name": "bundletwo", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", - "kwargs": {"local_folder": "/dev/null", "refresh_interval": 300}, + "kwargs": {"path": "/dev/null", "refresh_interval": 300}, }, ] @@ -900,7 +900,7 @@ def test_bundles_versions_are_stored(self): { "name": "mybundle", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", - "kwargs": {"local_folder": "/dev/null", "refresh_interval": 0}, + "kwargs": {"path": "/dev/null", "refresh_interval": 0}, }, ]