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

Remove callable functions parameter from kafka operator template_fields #42555

Merged
merged 1 commit into from
Sep 29, 2024

Conversation

gopidesupavan
Copy link
Member

@gopidesupavan gopidesupavan commented Sep 27, 2024

closes: #42502

The Kafka ConsumeFromTopicOperator and ProduceToTopicOperator are failing to resolve callable template fields. For a callable to work with template functions, it must accept both the context and jinja_env.

If we include producer_function and apply_function in the template fields, all current users will need to modify their scripts to accept both context and jinja_env. and some minor updates require in kafka operator.

I also tested another scenario where the function does accept context and jinja_env, but in the UI template field, it appears as a generated type object(please check below screenshot). Since there isn’t much value in displaying this field as a generated type object, I believe it's better to remove these from the template fields altogether.

Any other suggestion please?

image

Removed the fields and executed kafka system test.

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.

Copy link
Contributor

@shahar1 shahar1 left a comment

Choose a reason for hiding this comment

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

I'm not entirely sure that removing these parameters is the right way to deal with it (then you'll break compatibility with older Airflow versions where it works).
@uranusjr / @raphaelauv - I would be happy for your feedback.

@raphaelauv
Copy link
Contributor

raphaelauv commented Sep 28, 2024

Yes I did the same for #39948

That was the only callable that was in the templated_fields of the operator that I detected thanks to a unit test breaking

@gopidesupavan
Copy link
Member Author

I'm not entirely sure that removing these parameters is the right way to deal with it (then you'll break compatibility with older Airflow versions where it works). @uranusjr / @raphaelauv - I would be happy for your feedback.

Thanks for the review. Yes i completely agree. but IMHO keeping these parameters also cause problems here. https://github.com/apache/airflow/blob/main/airflow/models/abstractoperator.py#L768

here the callable value args has only context and jinja_env, if the function does accepts more arguments this would fail ?.

Happy for any other suggestions :)

@shahar1 shahar1 merged commit db1d12c into apache:main Sep 29, 2024
56 checks passed
joaopamaral pushed a commit to joaopamaral/airflow that referenced this pull request Oct 21, 2024
@gopidesupavan gopidesupavan deleted the fix-kafka-operators branch November 2, 2024 13:05
ellisms pushed a commit to ellisms/airflow that referenced this pull request Nov 13, 2024
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.

Apache Kafka operators ProduceToTopicOperator and ConsumeFromTopicOperator unusable since Airflow >= 2.10.0
3 participants