xBis7 commented on code in PR #43941:
URL: https://github.com/apache/airflow/pull/43941#discussion_r1885736416


##########
airflow/models/taskinstance.py:
##########
@@ -3731,6 +3814,12 @@ def from_ti(cls, ti: TaskInstance) -> SimpleTaskInstance:
             key=ti.key,
             run_as_user=ti.run_as_user if hasattr(ti, "run_as_user") else None,
             priority_weight=ti.priority_weight if hasattr(ti, 
"priority_weight") else None,
+            # Inspect the ti, to check if the 'dag_run' relationship is loaded.
+            parent_context_carrier=ti.dag_run.context_carrier
+            if "dag_run" not in inspect(ti).unloaded
+            else None,
+            context_carrier=ti.context_carrier if hasattr(ti, 
"context_carrier") else None,
+            span_status=ti.span_status if hasattr(ti, "span_status") else None,

Review Comment:
   Yes, you are right. There is a default value of `NOT_STARTED`.



##########
airflow/models/taskinstance.py:
##########
@@ -3731,6 +3814,12 @@ def from_ti(cls, ti: TaskInstance) -> SimpleTaskInstance:
             key=ti.key,
             run_as_user=ti.run_as_user if hasattr(ti, "run_as_user") else None,
             priority_weight=ti.priority_weight if hasattr(ti, 
"priority_weight") else None,
+            # Inspect the ti, to check if the 'dag_run' relationship is loaded.
+            parent_context_carrier=ti.dag_run.context_carrier
+            if "dag_run" not in inspect(ti).unloaded
+            else None,
+            context_carrier=ti.context_carrier if hasattr(ti, 
"context_carrier") else None,
+            span_status=ti.span_status if hasattr(ti, "span_status") else None,

Review Comment:
   I'll simplify it.



-- 
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