Skip to content

Conversation

@amoghrajesh
Copy link
Contributor

#46613 introduced a machinery for operator links to be used via xcoms and task sdk by introducing a new class XComOperatorLink and #47008 moved it to the task sdk. Now that I think about it, it should not reside in the task sdk because it is only used by the DAG processor while serialising / deserialising that too while actually running it (api servrer)

Moving it to serialised_objects instead, where its used.

Plugin present:
image

Plugin used:

from airflow.plugins_manager import AirflowPlugin
from airflow.sdk.definitions.baseoperatorlink import BaseOperatorLink
from airflow.providers.standard.operators.python import PythonOperator


# define the extra link
class HTTPDocsLink(BaseOperatorLink):
    # name the link button in the UI
    name = "HTTP docs"

    # add the button to one or more operators
    operators = [PythonOperator]

    # provide the link
    def get_link(self, operator, *, ti_key=None):
        return "https://developer.mozilla.org/en-US/docs/Web/HTTP"

# define the plugin class
class AirflowExtraLinkPlugin(AirflowPlugin):
    name = "extra_link_plugin"
    operator_extra_links = [
        HTTPDocsLink(),
    ]

Ran this dag:

from airflow.models.dag import DAG
2from pendulum import datetime
3
4from airflow.providers.standard.operators.python import PythonOperator
5
6
7def handler():
8    print("Hello from the python operator!!")
9
10with DAG(
11    dag_id="extra_links_plugin",
12    start_date=datetime(2022, 11, 1),
13    schedule=None,
14    catchup=False,
15    tags=["extra_links"],
16):
17
18    call_api_simple = PythonOperator(
19        task_id="call_api_simple",
20        python_callable=handler,
21    )

Extra link present:
image


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@amoghrajesh
Copy link
Contributor Author

Failures are unrelated to the changes made. Overriding and merging

@amoghrajesh amoghrajesh merged commit 37b03c1 into apache:main Mar 12, 2025
45 of 61 checks passed
@amoghrajesh amoghrajesh deleted the xcomoperatorlink-to-serialised-dag branch March 12, 2025 16:17
nailo2c pushed a commit to nailo2c/airflow that referenced this pull request Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants