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

Add @task.kubernetes taskflow decorator #25663

Merged
merged 10 commits into from
Aug 22, 2022
Merged

Add @task.kubernetes taskflow decorator #25663

merged 10 commits into from
Aug 22, 2022

Conversation

fletchjeff
Copy link
Contributor

@fletchjeff fletchjeff commented Aug 11, 2022

Adds the @task.kubernetes decorator to run arbitrary python code in a DAG in a k8s pod using the KubernetesPodOperator.

closes: #19135

This fixes some of the changes requested with pull request 21077. Shout out to @subkanthi who did most of the work, I just made the final requested changes.

The python_kubernetes_script.py and python_kubernetes_script.jinja2 are now in the airflow/providers/cncf/kubernetes folder.

Co-authored-by: subkanthi subkanthi@gmail.com


^ 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.

@boring-cyborg boring-cyborg bot added provider:cncf-kubernetes Kubernetes provider related issues area:providers labels Aug 11, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 11, 2022

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@uranusjr uranusjr changed the title Working @task.kubernetes decorator Add @task.kubernetes taskflow decorator Aug 11, 2022
@@ -147,7 +147,6 @@ class KubernetesPodOperator(BaseOperator):
to populate the environment variables with. The contents of the target
ConfigMap's Data field will represent the key-value pairs as environment variables.
Extends env_from.
:param: kubernetes_conn_id: To retrieve credentials for your k8s cluster from an Airflow connection
Copy link
Member

Choose a reason for hiding this comment

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

This docstring is duplicated; there’s already one near the top, so I took the chance to remove it.

@kaxil
Copy link
Member

kaxil commented Aug 12, 2022

Thanks for making this cross the finish line @fletchjeff

@kaxil
Copy link
Member

kaxil commented Aug 12, 2022

@fletchjeff @uranusjr Can one of you look at the failing tests please:

Feels related since those are provider failures only

@fletchjeff
Copy link
Contributor Author

fletchjeff commented Aug 12, 2022

Hi @kaxil , both of those failures seem to be related to snowflake connector.

Unknown warnings generated:
  
  /usr/local/lib/python3.7/site-packages/snowflake/connector/options.py:99:
You have an incompatible version of 'pyarrow' installed (5.0.0), please install a version that adheres to: 
'pyarrow<8.1.0,>=8.0.0; extra == "pandas"'

I see similar messages in the airflow/scripts/in_container/verify_providers.py file in KNOWN_DEPRECATED_MESSAGES e.g.

    (
        "You have an incompatible version of 'pyarrow' installed (6.0.1), please install a version that "
        "adheres to: 'pyarrow<8.1.0,>=8.0.0; extra == \"pandas\"'",
        "snowflake",
    )

@kaxil
Copy link
Member

kaxil commented Aug 14, 2022

Hi @kaxil , both of those failures seem to be related to snowflake connector.

Unknown warnings generated:
  
  /usr/local/lib/python3.7/site-packages/snowflake/connector/options.py:99:
You have an incompatible version of 'pyarrow' installed (5.0.0), please install a version that adheres to: 
'pyarrow<8.1.0,>=8.0.0; extra == "pandas"'

I see similar messages in the airflow/scripts/in_container/verify_providers.py file in KNOWN_DEPRECATED_MESSAGES e.g.

    (
        "You have an incompatible version of 'pyarrow' installed (6.0.1), please install a version that "
        "adheres to: 'pyarrow<8.1.0,>=8.0.0; extra == \"pandas\"'",
        "snowflake",
    )

Should be fixed by #25697 -- I have rebased the PR 🤞

@potiuk potiuk added this to the Airflow 2.4.0 milestone Aug 21, 2022
@uranusjr uranusjr self-assigned this Aug 22, 2022
@uranusjr uranusjr merged commit 0eb0b54 into apache:main Aug 22, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 22, 2022

Awesome work, congrats on your first merged pull request!

@kaxil
Copy link
Member

kaxil commented Aug 22, 2022

@fletchjeff Thanks for staying on top of this 🎉

@potiuk
Copy link
Member

potiuk commented Aug 22, 2022

wooooooohoooo 🎉

@fletchjeff
Copy link
Contributor Author

Thank you all!! Super excited to get to use this now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:cncf-kubernetes Kubernetes provider related issues type:new-feature Changelog: New Features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PythonKubernetesOperator and kubernetes taskflow decorator
6 participants