ferruzzi commented on code in PR #61153: URL: https://github.com/apache/airflow/pull/61153#discussion_r2791247636
########## airflow-core/src/airflow/executors/workloads/task.py: ########## @@ -0,0 +1,104 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""Task workload schemas for executor communication.""" + +from __future__ import annotations + +import uuid +from pathlib import Path +from typing import TYPE_CHECKING, Literal + +from pydantic import BaseModel, Field + +from airflow.executors.workloads.base import BaseDagBundleWorkload, BundleInfo + +if TYPE_CHECKING: + from airflow.api_fastapi.auth.tokens import JWTGenerator + from airflow.models.taskinstance import TaskInstance as TIModel + from airflow.models.taskinstancekey import TaskInstanceKey + + +class TaskInstanceDTO(BaseModel): + """Schema for TaskInstance with minimal required fields needed for Executors and Task SDK.""" + + id: uuid.UUID + dag_version_id: uuid.UUID + task_id: str + dag_id: str + run_id: str + try_number: int + map_index: int = -1 + + pool_slots: int + queue: str + priority_weight: int + executor_config: dict | None = Field(default=None, exclude=True) + + parent_context_carrier: dict | None = None + context_carrier: dict | None = None + + @property + def key(self) -> TaskInstanceKey: + """Return the TaskInstanceKey for this task instance.""" + from airflow.models.taskinstancekey import TaskInstanceKey + + return TaskInstanceKey( + dag_id=self.dag_id, + task_id=self.task_id, + run_id=self.run_id, + try_number=self.try_number, + map_index=self.map_index, + ) + + +class ExecuteTask(BaseDagBundleWorkload): + """Execute the given Task.""" + + ti: TaskInstanceDTO + sentry_integration: str = "" + + type: Literal["ExecuteTask"] = Field(init=False, default="ExecuteTask") + + @classmethod + def make( Review Comment: Here is the actual diff for these two classes with main on the left and the new on the right I did accidentally drop an existing todo from TaskInstance when I ported it over, which I have added back in, so I'll make another pass on the copypasta and make sure I didn't drop any other comments. <img width="1267" height="1310" alt="image" src="https://github.com/user-attachments/assets/dfc463fd-644c-4962-bafe-791c866ac6c9" /> -- 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]
