Failing KPO task wich task decorator and imported typing elements #40585
Labels
area:providers
kind:bug
This is a clearly a bug
provider:cncf-kubernetes
Kubernetes provider related issues
Apache Airflow Provider(s)
cncf-kubernetes
Versions of Apache Airflow Providers
8.3.2
Apache Airflow version
2.9.2
Operating System
rhel
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
What happened
Having specific
typing
elements that need to be imported generate an error when using@task.kubernetes
task decorator.See below for the specific of the errors.
What you think should happen instead
A solution could be to adjust the
get_python_source
function here : https://github.com/apache/airflow/blob/main/airflow/decorators/base.py#L301.We could add a step to remove the typing from the code (for the parameters part but also, if wished, in the code).
I have a solve ready using
ast
andastunparse
.How to reproduce
I obtain the following results:
my_task0
is supposed to run as proof that everything is finemy_task1
is supposed to fail because thefrom typing import Any
is not added in the/tmp/scripts.py
file. The interesting log portion:my_task2
is also supposed to fail, because the definition of theMyObject
is not ported to/tmp/scripts.py
and may never be since the created pod migt not contain the class definition.my_task3
, I was expecting a failure sincefrom typing import Any
is not in the/tmp/script.py
file (as formy_task2
). But it appears that is does not raise errors. Thus we do not need to solve this none existing problem.Anything else
This issue should also appear for
@task.docker
. But I have not tested it.Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: