Skip to content

Commit f42ffbc

Browse files
authored
Fix backward compatibility for workloads TaskInstance import (#62714)
Re-export TaskInstance from airflow.executors.workloads as an alias to TaskInstanceDTO so integrations using the legacy import path continue to work. Add a regression test that verifies the alias remains available.
1 parent 4d3230c commit f42ffbc

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

airflow-core/src/airflow/executors/workloads/__init__.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,23 @@
2424

2525
from airflow.executors.workloads.base import BaseWorkload, BundleInfo
2626
from airflow.executors.workloads.callback import CallbackFetchMethod, ExecuteCallback
27-
from airflow.executors.workloads.task import ExecuteTask
27+
from airflow.executors.workloads.task import ExecuteTask, TaskInstanceDTO
2828
from airflow.executors.workloads.trigger import RunTrigger
2929

3030
All = Annotated[
3131
ExecuteTask | ExecuteCallback | RunTrigger,
3232
Field(discriminator="type"),
3333
]
3434

35-
__all__ = ["All", "BaseWorkload", "BundleInfo", "CallbackFetchMethod", "ExecuteCallback", "ExecuteTask"]
35+
TaskInstance = TaskInstanceDTO
36+
37+
__all__ = [
38+
"All",
39+
"BaseWorkload",
40+
"BundleInfo",
41+
"CallbackFetchMethod",
42+
"ExecuteCallback",
43+
"ExecuteTask",
44+
"TaskInstance",
45+
"TaskInstanceDTO",
46+
]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
from __future__ import annotations
19+
20+
from airflow.executors import workloads
21+
from airflow.executors.workloads import TaskInstance, TaskInstanceDTO
22+
23+
24+
def test_task_instance_alias_keeps_backwards_compat():
25+
assert TaskInstance is TaskInstanceDTO
26+
assert workloads.TaskInstance is TaskInstanceDTO
27+
assert workloads.TaskInstanceDTO is TaskInstanceDTO

0 commit comments

Comments
 (0)