This is an automated email from the ASF dual-hosted git repository.
amoghdesai pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-0-test by this push:
new 0ca20b106f8 [v3-0-test] Move macros to task SDK execution_time module
(#50940) (#50953)
0ca20b106f8 is described below
commit 0ca20b106f8890cea2824c534e52887818e09757
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu May 22 21:18:25 2025 +0530
[v3-0-test] Move macros to task SDK execution_time module (#50940) (#50953)
(cherry picked from commit f7b8ccd311d41106ff57e54187a25f7cff1fa590)
Co-authored-by: Amogh Desai <[email protected]>
---
airflow-core/src/airflow/macros/__init__.py | 2 +-
airflow-core/src/airflow/plugins_manager.py | 4 ++--
airflow-core/tests/unit/plugins/test_plugins_manager.py | 12 ++++++------
task-sdk/src/airflow/sdk/execution_time/context.py | 4 ++--
.../airflow/sdk/{definitions => execution_time}/macros.py | 0
task-sdk/tests/task_sdk/definitions/test_macros.py | 2 +-
6 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/airflow-core/src/airflow/macros/__init__.py
b/airflow-core/src/airflow/macros/__init__.py
index 4d858a1c751..95874ac43b4 100644
--- a/airflow-core/src/airflow/macros/__init__.py
+++ b/airflow-core/src/airflow/macros/__init__.py
@@ -17,7 +17,7 @@
# under the License.
from __future__ import annotations
-from airflow.sdk.definitions.macros import ( # noqa: F401
+from airflow.sdk.execution_time.macros import ( # noqa: F401
datetime,
datetime_diff_for_humans,
dateutil,
diff --git a/airflow-core/src/airflow/plugins_manager.py
b/airflow-core/src/airflow/plugins_manager.py
index a83236ea0c8..8d4319b6997 100644
--- a/airflow-core/src/airflow/plugins_manager.py
+++ b/airflow-core/src/airflow/plugins_manager.py
@@ -507,7 +507,7 @@ def integrate_macros_plugins() -> None:
global plugins
global macros_modules
- from airflow.sdk.definitions import macros
+ from airflow.sdk.execution_time import macros
if macros_modules is not None:
return
@@ -525,7 +525,7 @@ def integrate_macros_plugins() -> None:
if plugin.name is None:
raise AirflowPluginException("Invalid plugin name")
- macros_module =
make_module(f"airflow.sdk.definitions.macros.{plugin.name}", plugin.macros)
+ macros_module =
make_module(f"airflow.sdk.execution_time.macros.{plugin.name}", plugin.macros)
if macros_module:
macros_modules.append(macros_module)
diff --git a/airflow-core/tests/unit/plugins/test_plugins_manager.py
b/airflow-core/tests/unit/plugins/test_plugins_manager.py
index 28843faa702..3b61297f0b1 100644
--- a/airflow-core/tests/unit/plugins/test_plugins_manager.py
+++ b/airflow-core/tests/unit/plugins/test_plugins_manager.py
@@ -229,17 +229,17 @@ class TestPluginsManager:
Tests whether macros that originate from plugins are being registered
correctly.
"""
from airflow.plugins_manager import integrate_macros_plugins
- from airflow.sdk.definitions import macros
+ from airflow.sdk.execution_time import macros
def cleanup_macros():
"""Reloads the macros module such that the symbol table is reset
after the test."""
# We're explicitly deleting the module from sys.modules and
importing it again
# using import_module() as opposed to using importlib.reload()
because the latter
- # does not undo the changes to the airflow.sdk.definitions.macros
module that are being caused by
+ # does not undo the changes to the
airflow.sdk.execution_time.macros module that are being caused by
# invoking integrate_macros_plugins()
- del sys.modules["airflow.sdk.definitions.macros"]
- importlib.import_module("airflow.sdk.definitions.macros")
+ del sys.modules["airflow.sdk.execution_time.macros"]
+ importlib.import_module("airflow.sdk.execution_time.macros")
request.addfinalizer(cleanup_macros)
@@ -254,12 +254,12 @@ class TestPluginsManager:
# Ensure the macros for the plugin have been integrated.
integrate_macros_plugins()
# Test whether the modules have been created as expected.
- plugin_macros =
importlib.import_module(f"airflow.sdk.definitions.macros.{MacroPlugin.name}")
+ plugin_macros =
importlib.import_module(f"airflow.sdk.execution_time.macros.{MacroPlugin.name}")
for macro in MacroPlugin.macros:
# Verify that the macros added by the plugin are being set
correctly
# on the plugin's macro module.
assert hasattr(plugin_macros, macro.__name__)
- # Verify that the symbol table in airflow.sdk.definitions.macros
has been updated with an entry for
+ # Verify that the symbol table in
airflow.sdk.execution_time.macros has been updated with an entry for
# this plugin, this is necessary in order to allow the plugin's
macros to be used when
# rendering templates.
assert hasattr(macros, MacroPlugin.name)
diff --git a/task-sdk/src/airflow/sdk/execution_time/context.py
b/task-sdk/src/airflow/sdk/execution_time/context.py
index 63a166920f6..e8b4cb9b6a0 100644
--- a/task-sdk/src/airflow/sdk/execution_time/context.py
+++ b/task-sdk/src/airflow/sdk/execution_time/context.py
@@ -341,9 +341,9 @@ class MacrosAccessor:
def __getattr__(self, item: str) -> Any:
# Lazily load Macros module
if not self._macros_module:
- import airflow.sdk.definitions.macros
+ import airflow.sdk.execution_time.macros
- self._macros_module = airflow.sdk.definitions.macros
+ self._macros_module = airflow.sdk.execution_time.macros
return getattr(self._macros_module, item)
def __repr__(self) -> str:
diff --git a/task-sdk/src/airflow/sdk/definitions/macros.py
b/task-sdk/src/airflow/sdk/execution_time/macros.py
similarity index 100%
rename from task-sdk/src/airflow/sdk/definitions/macros.py
rename to task-sdk/src/airflow/sdk/execution_time/macros.py
diff --git a/task-sdk/tests/task_sdk/definitions/test_macros.py
b/task-sdk/tests/task_sdk/definitions/test_macros.py
index 08f584854a5..cb471934f00 100644
--- a/task-sdk/tests/task_sdk/definitions/test_macros.py
+++ b/task-sdk/tests/task_sdk/definitions/test_macros.py
@@ -23,7 +23,7 @@ import lazy_object_proxy
import pendulum
import pytest
-from airflow.sdk.definitions import macros
+from airflow.sdk.execution_time import macros
@pytest.mark.parametrize(