dabla commented on code in PR #55068:
URL: https://github.com/apache/airflow/pull/55068#discussion_r2671388056


##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########
@@ -944,9 +975,19 @@ async def init_comms(self):
             raise RuntimeError(f"Required first message to be a 
messages.StartTriggerer, it was {msg}")
 
     async def create_triggers(self):
+        def create_runtime_ti(encoded_dag: dict) -> RuntimeTaskInstance:
+            task = 
DagSerialization.from_dict(encoded_dag).get_task(workload.ti.task_id)
+
+            # I need to recreate a TaskInstance from task_runner before 
invoking get_template_context (airflow.executors.workloads.TaskInstance)
+            return RuntimeTaskInstance.model_construct(
+                **workload.ti.model_dump(exclude_unset=True),
+                task=task,
+            )

Review Comment:
   This part in airflow.models.taskinstance, which has now be modified without 
support for mapped tasks:
   
       ```
   def to_runtime(self) -> RuntimeTaskInstance:
           from airflow.sdk.execution_time.task_runner import 
RuntimeTaskInstance
   
           return RuntimeTaskInstance.model_construct(
               id=self.id,
               task_id=self.task_id,
               dag_id=self.dag_id,
               run_id=self.run_id,
               try_number=self.try_number,
               dag_version_id=self.dag_version_id,
               map_index=self.map_index,
               hostname=self.hostname,
               task=self.task,
               max_tries=self.max_tries,
               start_date=self.start_date,
               end_date=self.end_date,
               state=self.state,
               rendered_map_index=self.rendered_map_index,
           )
   
       @property
       def start_trigger_args(self) -> StartTriggerArgs | None:
           if self.task:
               if self.task.is_mapped:
                   context = self.to_runtime().get_template_context()
                   if self.task.expand_start_from_trigger(context=context):
                       return 
self.task.expand_start_trigger_args(context=context)
               elif self.task.start_from_trigger is True:
                   return self.task.start_trigger_args
           return None
   ```



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