Skip to content

Conversation

@amoghrajesh
Copy link
Contributor

Why?

We moved the BaseOperatorLink to use a new machinery in #46609. BaseOperatorLink should reside now in the task sdk instead of models. This PR attempts to do that.

Testing

I have defined some plugins:

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(),
    ]

DAG used:

from airflow.models.dag import DAG
from pendulum import datetime

from airflow.providers.standard.operators.python import PythonOperator


def handler():
    print("Hello from the python operator!!")

with DAG(
    dag_id="extra_links_plugin",
    start_date=datetime(2022, 11, 1),
    schedule=None,
    catchup=False,
    tags=["extra_links"],
):

    call_api_simple = PythonOperator(
        task_id="call_api_simple",
        python_callable=handler,
    )

Loaded in UI:
image

Green run:
image

Button:
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 amoghrajesh requested a review from Lee-W February 24, 2025 14:58
@amoghrajesh amoghrajesh closed this Mar 3, 2025
@amoghrajesh amoghrajesh reopened this Mar 3, 2025
@amoghrajesh
Copy link
Contributor Author

Finally got a green run on this one!

Copy link
Member

@ashb ashb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, a few nits/small changes. Pre-approving once those are done

@amoghrajesh
Copy link
Contributor Author

Damn this will need a rebase now!

@amoghrajesh
Copy link
Contributor Author

Just rebased it, will wait for the CI and merge :)

@amoghrajesh amoghrajesh merged commit aa07160 into apache:main Mar 7, 2025
148 checks passed
@amoghrajesh amoghrajesh deleted the AIP72-baseoperatorlink-to-sdk branch March 7, 2025 08:24
@amoghrajesh amoghrajesh linked an issue Mar 10, 2025 that may be closed by this pull request
1 task
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.

Move BaseOperatorLink to task sdk

3 participants