travis-cook-sfdc commented on issue #28870:
URL: https://github.com/apache/airflow/issues/28870#issuecomment-1386213733
This is different than implementing multiple OperatorLinks for a few reasons:
- The number of links required is unknown at instantiation. It's dependent
on the instance of the operator and not the generic operator.
- The button name is hardcoded by the link, but in this case, you'd want it
to be dynamic based on the task name.
Imagine this operator:
```
class ExternalTask:
dag_id: str
task_id: str
class MultiExternalTaskSensor(BaseSensorOperator):
def __init__(external_tasks: List[ExternalTask], ...):
....
```
And then the following dags:
```
dag_1 = Dag(...)
wf_upstreams = MultiExternalTaskSensor(
task_id="wf_upstreams",
dag=dag_1,
external_tasks=[
ExternalTask(dag_id="upstream_foo", task_id="bar"),
ExternalTask(dag_id="upstream_bat", task_id="baz")
]
)
...
dag_2 = Dag(...)
wf_upstreams = MultiExternalTaskSensor(
task_id="wf_upstreams",
dag=dag_2,
external_tasks=[
ExternalTask(dag_id="upstream_foo1", task_id="bar1"),
ExternalTask(dag_id="upstream_foo2", task_id="bar2"),
ExternalTask(dag_id="upstream_foo3", task_id="bar3"),
]
)
```
When you open the modal for `dag_1.wf_upstreams`, you should 2 buttons with
the name `upstream_foo` and `upstream_bar`.
When you open the modal for `dag_2.wf_upstreams`, you should see 3 buttons
with the names `upstream_foo1`, `upstream_foo2`, and `upstream_foo3`.
AFAIK, `BaseOperatorLink` doesn't allow you to set a dynamic number of links
based on a task instance attribute nor does it allow you to set dynamic button
names. I'd be delighted to be wrong though!
--
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]