fredthomsen opened a new issue, #54527:
URL: https://github.com/apache/airflow/issues/54527

   ### Description
   
   Enable easy setting of a extra link(s) within a task-decorated/TaskFlow 
function.  Currently one must create an custom operator for this functionality 
and define an extra link class, and thus extra links are not utilized for some 
one-off tasks by DAG authors where they could be very useful and provide value.
   
   ### Use case/motivation
   
   Provide a common and easy setting of extra links within task-decorated 
functions that enables DAG authors to:
   - Very easily add extra link(s) to their new or pre-existing task decorated 
functions.
   - Support for multiple extra links for a single function
   - Does not require altering the return value of the function
   - Overrides any extra links w/same name for this task instance
   
   For example as a separate decorator:
   ``` 
   @with_extra_links("API Resource")
   @task
   def get_api_resource(id_: str):
       """
       Example of setting extra link w/a separate decorator with link name `API 
Resource`.
       """
       rsp = requests.get(f"https://localhost/v2/api/fakeresource/{id_}";)
       set_extra_link("API Resource", rsp.url)
       return rsp.json()
   ```
   
   Or adjusting the existing decorator:
   ```
   @task(extra_links=["API Resource"])
   def get_api_resource(id_: str):
       """
       Example of setting extra link w/a separate decorator with link name `API 
Resource`.
       """
       rsp = requests.get(f"https://localhost/v2/api/fakeresource/{id_}";)
       set_extra_link("API Resource", rsp.url)
       return rsp.json()
   
   ```
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to