dabla commented on code in PR #55068:
URL: https://github.com/apache/airflow/pull/55068#discussion_r2468472909
##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########
@@ -915,6 +943,15 @@ 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(dag: dict) -> RuntimeTaskInstance:
+ task = SerializedDAG.from_dict(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:
Are you sure about that? Because I checked the instance at runtime before
the fix, and it was this class from airflow.sdk.api.datamodels._generated
module:
```
class TaskInstance(BaseModel):
"""
Schema for TaskInstance model with minimal required fields needed for
Runtime.
"""
id: Annotated[UUID, Field(title="Id")]
task_id: Annotated[str, Field(title="Task Id")]
dag_id: Annotated[str, Field(title="Dag Id")]
run_id: Annotated[str, Field(title="Run Id")]
try_number: Annotated[int, Field(title="Try Number")]
dag_version_id: Annotated[UUID, Field(title="Dag Version Id")]
map_index: Annotated[int | None, Field(title="Map Index")] = -1
hostname: Annotated[str | None, Field(title="Hostname")] = None
context_carrier: Annotated[dict[str, Any] | None, Field(title="Context
Carrier")] = None
```
So personally I think we are good here.
--
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]