phi-friday commented on code in PR #41039:
URL: https://github.com/apache/airflow/pull/41039#discussion_r1703983380


##########
airflow/utils/python_virtualenv.py:
##########
@@ -149,3 +157,76 @@ def write_python_script(
         )
     template = template_env.get_template("python_virtualenv_script.jinja2")
     template.stream(**jinja_context).dump(filename)
+
+
+def context_to_json(context: Context) -> str:

Review Comment:
   @potiuk 
   There is no specific error when serializing as you said, but the 
`task_instance` is serialized as follows. 
   
   ```shell
   [2024-08-05, 10:00:10 UTC] {process_utils.py:191} INFO -            
'task_instance': '<TaskInstance: '
   [2024-08-05, 10:00:10 UTC] {process_utils.py:191} INFO -                     
        'example_python_context_decorator.print_the_context_venv '
   [2024-08-05, 10:00:10 UTC] {process_utils.py:191} INFO -                     
        'manual__2024-08-05T09:59:59.292358+00:00 '
   [2024-08-05, 10:00:10 UTC] {process_utils.py:191} INFO -                     
        '[running]>',
   ```
   
   Since `task_instance` is used frequently, I think it would be better to use 
`BaseSerialization` for serialization and replace `task_instance` with 
`SimpleTaskInstance`. What do you think?



-- 
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-unsubscr...@airflow.apache.org

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

Reply via email to