diff --git a/providers/openlineage/src/airflow/providers/openlineage/plugins/listener.py b/providers/openlineage/src/airflow/providers/openlineage/plugins/listener.py index c49880237b8a7..4b500157d3a64 100644 --- a/providers/openlineage/src/airflow/providers/openlineage/plugins/listener.py +++ b/providers/openlineage/src/airflow/providers/openlineage/plugins/listener.py @@ -104,7 +104,7 @@ def on_task_instance_running( assert task dagrun = context["dag_run"] dag = context["dag"] - start_date = context["start_date"] + start_date = task_instance.start_date self._on_task_instance_running(task_instance, dag, dagrun, task, start_date) else: diff --git a/providers/standard/src/airflow/providers/standard/operators/python.py b/providers/standard/src/airflow/providers/standard/operators/python.py index 1eecd736f998c..56ed7306c6919 100644 --- a/providers/standard/src/airflow/providers/standard/operators/python.py +++ b/providers/standard/src/airflow/providers/standard/operators/python.py @@ -394,8 +394,6 @@ class _BasePythonVirtualenvOperator(PythonOperator, metaclass=ABCMeta): "prev_execution_date", "prev_execution_date_success", } - if AIRFLOW_V_3_0_PLUS: - PENDULUM_SERIALIZABLE_CONTEXT_KEYS.add("start_date") AIRFLOW_SERIALIZABLE_CONTEXT_KEYS = { "macros", diff --git a/task_sdk/src/airflow/sdk/execution_time/task_runner.py b/task_sdk/src/airflow/sdk/execution_time/task_runner.py index 99967579bb493..61a4f7f25bf98 100644 --- a/task_sdk/src/airflow/sdk/execution_time/task_runner.py +++ b/task_sdk/src/airflow/sdk/execution_time/task_runner.py @@ -139,7 +139,6 @@ def get_template_context(self) -> Context: # TODO: Ensure that ti.log_url and such are available to use in context # especially after removal of `conf` from Context. "ti": self, - "start_date": self.start_date, "outlet_events": OutletEventAccessors(), # "inlet_events": InletEventsAccessors(task.inlets, session=session), "macros": MacrosAccessor(), diff --git a/task_sdk/src/airflow/sdk/types.py b/task_sdk/src/airflow/sdk/types.py index 795130bf37462..cdbdc225b9cf7 100644 --- a/task_sdk/src/airflow/sdk/types.py +++ b/task_sdk/src/airflow/sdk/types.py @@ -63,6 +63,7 @@ class RuntimeTaskInstanceProtocol(Protocol): map_index: int | None max_tries: int hostname: str | None = None + start_date: datetime def xcom_pull( self, diff --git a/task_sdk/tests/execution_time/test_task_runner.py b/task_sdk/tests/execution_time/test_task_runner.py index 5e4405165e235..0db74681f3f1a 100644 --- a/task_sdk/tests/execution_time/test_task_runner.py +++ b/task_sdk/tests/execution_time/test_task_runner.py @@ -823,7 +823,6 @@ def test_get_context_without_ti_context_from_server(self, mocked_parse, make_ti_ "outlet_events": OutletEventAccessors(), "outlets": task.outlets, "run_id": "test_run", - "start_date": start_date, "task": task, "task_instance": runtime_ti, "ti": runtime_ti, @@ -869,7 +868,6 @@ def test_get_context_with_ti_context_from_server(self, create_runtime_ti, mock_s "prev_end_date_success": timezone.datetime(2024, 12, 1, 1, 0, 0), "prev_start_date_success": timezone.datetime(2024, 12, 1, 0, 0, 0), "run_id": "test_run", - "start_date": timezone.datetime(2024, 12, 1, 1, 0), "task": task, "task_instance": runtime_ti, "ti": runtime_ti,