PythonVirtualenvOperator: render_template_as_native_obj=True causes PicklingError when using {{ ti }} / {{ task_instance }} (cloudpickle/structlog)
#61231
Unanswered
akhundovte
asked this question in
Ideas
Replies: 3 comments
-
|
I recently encountered the same problem. It worked on airflow 2, but not on version 3. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Same here |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I suggest you open an issue about it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Airflow team,
The PythonVirtualenvOperator docs (“Passing in arguments”) mention that Airflow does not support serializing ti / task_instance. I understand this limitation and that a workaround is to pass only identifiers and, if needed, fetch task instance data via the Airflow API.
However, I found a reproducible case where the behavior changes depending on render_template_as_native_obj, and enabling native rendering makes the task fail during argument serialization.
Minimal repro
Observation
Error with render_template_as_native_obj=True
Questions
Can you confirm whether this behavior difference is an expected consequence of render_template_as_native_obj=True (Jinja NativeEnvironment), where {{ ti }} / {{ task_instance }} render to native objects that then get pickled for PythonVirtualenvOperator?
Is there any plan to provide a supported mechanism for isolated environments instead of passing the “live” TaskInstance object, for example:
I understand one can call the Airflow API directly, but an official/supported approach (or at least clearer validation / a more explicit error message for this case) would be very helpful.
Environment
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions