Replies: 2 comments 2 replies
-
|
No. This control is per DAG. Sure. Opening a PR fixing it makes sense, I also personally think render_template_as_native_object could be a task parameter. But not sure if others will agree Maybe you can even contribute it. proposing a PR is the best way to start a discussion on it - you can also create an issue which hopefully somoene will pick up and implement, but implementing it on your own is the most certain way it will be looked at. |
Beta Was this translation helpful? Give feedback.
-
|
I started as a discussion because I could have missed something, and maybe there is a way of making it work with current setup? I have run into a corner case, where I want to do "dumb" string templating for some fields, and "typed" for others. I tried many workarounds and cannot make it work:
but it doesn't help, as the templating is configured globally and the setting conflicts later. If it is indeed impossible to achieve with the way the templating works in Airflow currently, I think it would be a very useful feature. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi.
I have extended the
KubernetesPodOperatoradding some extra properties to be templated, so I can configure them through Airflow variables:The parent class requires
log_events_on_failureandis_delete_operator_podarguments to be boolean.The arguments have correct types, but only when DAG is initialized with
render_template_as_native_obj = Trueon the DAG-level. Otherwise they will always be True, as"False"string evaluates toTrueboolean.This is not ideal, as sometimes we would like to render some of the Tasks with dumb strings and some other with proper types. Also, it would make it easier to have the operator working as intended without the need of special configuration on the DAG level. So we would generally want to be able to configure whether the templated fields are rendered as native objects or string, task by task.
Currently, I see no way of making it work. I tried overriding the
render_template_fieldsmethod on in myCustomKubernetesPodOperator, to enforcejinja_env = airflow.templates.NativeEnvironment()but during the rendering of the task instance, the value ofrender_template_as_native_objfrom the DAG is still used and breaks:Is there something I am missing to achieve the behavior I would like to see? Is it reasonable to ask for more granular control over what is rendered in what way as a Feature request?
Beta Was this translation helpful? Give feedback.
All reactions