eladkal commented on PR #46913:
URL: https://github.com/apache/airflow/pull/46913#issuecomment-2803116054

   > > How does this differ from 
https://github.com/apache/airflow/blob/main/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/decorators/kubernetes.py
 ?
   > 
   > @ashb The difference is similar to `@task.python` vs `@task.bash`.
   > 
   > The existing `@task.kubernetes` decorator is designed to run a Python 
function inside a Kubernetes pod using KPO. It does this by serializing the 
function into a temporary Python script that is executed inside the container. 
This is well-suited for cases where you want to isolate Python code execution 
and manage complex dependencies, as described in the [TaskFlow API 
documentation](https://airflow.apache.org/docs/apache-airflow/2.10.5/tutorial/taskflow.html#using-the-taskflow-api-with-complex-conflicting-python-dependencies).
   > 
   > In contrast, the new `@task.kubernetes_cmd` decorator allows the decorated 
function to return a shell command (as a list of strings), which is then passed 
as `cmds` or `arguments` to KPO. This enables executing arbitrary logic inside 
a Kubernetes pod -- without needing to wrap it in Python code.
   > 
   > A key benefit here is that Python excels at composing and templating these 
commands. Users can dynamically build shell commands using Python's string 
formatting, templating, and logic -- making it a flexible tool for 
orchestrating complex pipelines where the task is to invoke CLI-based 
operations in containers.
   > 
   > This bridges a gap between TaskFlow and general-purpose Kubernetes command 
execution. It makes Airflow more expressive for use cases where Python is just 
the glue, not the runtime. And allows omitting writing KPO-/cmds-generating 
functions for such cases.
   
   I imagine users will ask the same question.
   Can you add this to the docs?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to