-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Description
Apache Airflow version
2.10.2
If "Other Airflow 2 version" selected, which one?
No response
What happened?
Extra external links are not appearing on mapped tasks.
What you think should happen instead?
While I am able to add extra external links to an existing operator (the PythonOperator in this case) and able to view them in the UI, I am not able see the extra links when using mapped tasks of the same operator.
In this screenshot, I have a non-mapped task version of a simple DAG using the PythonOperator and the extra external link button is visible.

In this screenshot, I have a mapped task version of the same DAG using the PythonOperator and the extra external link is not visible.

How to reproduce
Create a new directory and run astro dev init.
Create a file named my_extra_link_plugin.py with the following code and add it to the plugins folder:
from airflow.models.baseoperator import BaseOperator
from airflow.models.baseoperator import BaseOperatorLink
from airflow.models.taskinstancekey import TaskInstanceKey
from airflow.operators.python import PythonOperator
from airflow.plugins_manager import AirflowPlugin
# define the extra link
class PythonDocsLink(BaseOperatorLink):
# name the link button in the UI
name = "Python Docs"
# add the button to one or more operators
operators = [PythonOperator]
# provide the link
def get_link(self, operator: BaseOperator, *, ti_key: TaskInstanceKey):
return "https://docs.python.org/3/"
# define the plugin class
class AirflowExtraLinkPlugin(AirflowPlugin):
name = "extra_link_plugin"
operator_extra_links = [
PythonDocsLink(),
]
In the dags folder, create a file named add.py that contains the following:
from pendulum import datetime
from airflow.models.dag import DAG
from airflow.operators.python import PythonOperator
with DAG(
dag_id="add",
schedule=None,
start_date=datetime(2024, 11, 3),
catchup=False,
) as dag:
def add_function(x: int, y: int):
return x + y
added_values = PythonOperator(
task_id="add",
python_callable=add_function,
op_kwargs={"x": 7, "y": 10},
)
In the dags folder, create a file named add_mapped_task.py that contains the following:
from pendulum import datetime
from airflow.models.dag import DAG
from airflow.operators.python import PythonOperator
with DAG(
dag_id="add_with_mapped_tasks",
schedule=None,
start_date=datetime(2024, 11, 3),
catchup=False,
) as dag:
def add_function(x: int, y: int):
return x + y
added_values = PythonOperator.partial(
task_id="add",
python_callable=add_function,
op_kwargs={"y": 10},
# optionally, you can set a custom index to display in the UI (Airflow 2.9+)
map_index_template="Input x={{ task.op_args[0] }}",
).expand(op_args=[[1], [2], [3]])
Trigger both DAGs and click on the Details tab.
Operating System
Sonoma 14.7
Versions of Apache Airflow Providers
No response
Deployment
Astronomer
Deployment details
Using Astronomer Runtime 12.2.0
Anything else?
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct