-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multiple buttons from operator_extra_links
#28870
Comments
Thanks for opening your first issue here! Be sure to follow the issue template! |
As long as it backwards compatible - sure. If you would like to contribute it, that works ld be great - it does not pass the bar of being super simple but for experienced person it might be interesting one to learn how things work. Marking as good first issue. |
How is this different from implementing multiple OperatorLink classes for the operator? |
Ah ... I completely forgot that we can do that.... I guess we can close that one then - if this does not work for you @travis-cook-sfdc , I will close it. We can re-open if you think that using multiple links is not good and have some good justification. |
This is different than implementing multiple OperatorLinks for a few reasons:
Imagine this operator:
And then the following dags:
When you open the modal for When you open the modal for AFAIK, |
airflow/airflow/providers/google/cloud/operators/bigquery.py Lines 85 to 107 in 4f91931
|
We can probably add something like class MyOperator(BaseOperator):
operator_extra_links = MyOperatorExtraLinkCollection() # Not a list of links! to encapsulate this pattern. Probably makes more sense than having a |
nice discussion. I see the problem now, and yeah, I agree having support for dynamic collection of links in operator is a better idea |
Updated the description to reflect this |
@Taragolis - Interesting example. I thought I had tried something similar, but I ran into problems when I attempted to register subclass of |
After a little more investigation, I think that example only works because the extra link is registered as a provider which doesn't require explicit instantiation. If you want to register it as a plugin, i.e.:
You have to specify an index which forces an explicit number of buttons at a time when it's unknown. |
@potiuk - It does seem like https://github.com/apache/airflow/blob/main/airflow/models/baseoperator.py#L634 Assuming you write
I think the issue has to do with how those extra links are registered as plugins but perhaps I'm not understanding how this could be implemented correctly? |
Using property is not supported because internally Airflow expects an iterable. Although this gives me an idea, we may be able to detect Note that these are (roughly) equivalent in Python: @property
def operator_extra_links(self, ...): ...
# and
def _get_operator_extra_links(...): ...
operator_extra_links = property(_get_operator_extra_links) and the latter variant is very similar to instantiating an |
I'm interesting in potentially implementing this change, but it's not clear to me exactly what the implementation should look like. Can anyone provide a summary? |
Assuming we go with the airflow/airflow/serialization/serialized_objects.py Lines 1086 to 1109 in b5b1fae
Here is a report where a property object crashes on serialisation: #25243 Everything else should be easy enough if we can fix this. |
Noting that #25243 is resolved. |
Description
UPDATE (@potiuk): Seems that better idea is to add support for dynamic collections of links to the operator rather than extend link to support multiple of those.
BaseOperatorLink
should support returning multiple links:Use case/motivation
My company has implemented a "MultiExternalTaskSensor" that allows a single task to wait for multiple other tasks to complete.
ExternalTaskSensor
automatically supportsoperator_extra_links
to provide a link to the upstream DAG page, but this is impossible to do withMulti...
since there's an arbitrary number of buttons that need to show up based on the number of tasks that are being waited on.Another benefit of allowing this would be that the buttons could support dynamic names, which would allow information about the task (like it's state) to present in the button text.
This would add an additional challenge while the button data was loading, since the name might not be known. At this point, there could either be a default name fallback or a simple loading spinner while we wait for all button names to return.
There would need to be changes to the
/extra_links
API anddag.js
, but it seems feasible.It could be implement along the lines of:
Related issues
No response
Are you willing to submit a PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: