You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "arunppsg (via GitHub)" <gi...@apache.org> on 2026/10/11 17:01:22 UTC

Re: [I] PythonVirtualenvOperator: native template rendering breaks {{ ti }} / {{ task_instance }} pickling [airflow]

arunppsg commented on issue #61741:
URL: https://github.com/apache/airflow/issues/61741#issuecomment-6111458499

   I think that we can maybe directly pass the required attributes of task instance, something like:
   ```py
   def venv_test(ti_id, ti_task_id):
       print("ti_id = ", ti_id)
       print("ti_task_id = ", ti_task_id)
   
   
   @dag(
       start_date=datetime(2026, 1, 1),
       schedule=None,
       catchup=False,
       # render_template_as_native_obj=False,  # <-- changing only this flips behavior
       render_template_as_native_obj=True,  # <-- changing only this flips behavior
   )
   def test_simple2():
       PythonVirtualenvOperator(
           task_id="repro",
           python_callable=venv_test,
           python_version="3.10",
           serializer="cloudpickle",
           op_kwargs={
               # "ti": "{{ ti }}",
               # "task_instance": "{{ task_instance }}",
               "ti_id": " {{ ti.id }}",
               "ti_task_id": " {{ ti.task_id }}",
           },
           requirements=["apache-airflow==3.1.6"],
           system_site_packages=False,
       )
   
   
   test_simple2()
   ```


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org