Skip to content
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

Fix a bug with accessing hooks in EKS trigger #35989

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

hussein-awala
Copy link
Member

The hook is defined as a standard method; converting it to a cached property is a breaking change. The best solution is to call this method to get the hook,

@vincbeck
Copy link
Contributor

Another option could be to create the hook as a cached property and use this property in the code. To keep it backward compatible, you can just return the property in the method

@hussein-awala
Copy link
Member Author

Another option could be to create the hook as a cached property and use this property in the code. To keep it backward compatible, you can just return the property in the method

The compatibility issue is not for us, but for the users who extend the trigger and create a subclass of it. Triggers are part of the Airflow public interface.

@vincbeck
Copy link
Contributor

Another option could be to create the hook as a cached property and use this property in the code. To keep it backward compatible, you can just return the property in the method

The compatibility issue is not for us, but for the users who extend the trigger and create a subclass of it. Triggers are part of the Airflow public interface.

I understand but why that would not be backward compatible for these users?

@hussein-awala
Copy link
Member Author

Currently, hook is a standard method, so if someone extends the trigger, he should use:

self.hook()

If we convert it to a cached_property, self.hook will return the hook, and the () will be applied on its value. A simple example:

>>> from functools import cached_property
>>> class X:
...     @cached_property
...     def x(self):
...             return 1
... 
>>> X().x()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable

@vincbeck
Copy link
Contributor

Oh yeah, I did not realize the 2 methods would have the same name. You can name the cached property method eks_hook but I guess it goes against the convention

@hussein-awala hussein-awala merged commit 8346fd5 into apache:main Nov 30, 2023
46 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:amazon-aws AWS/Amazon - related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants