amoghrajesh commented on code in PR #44241:
URL: https://github.com/apache/airflow/pull/44241#discussion_r1855938558
##########
airflow/api_fastapi/execution_api/datamodels/taskinstance.py:
##########
@@ -61,6 +62,28 @@ class TITargetStatePayload(BaseModel):
state: IntermediateTIState
+class TIDeferredStatePayload(BaseModel):
+ """Schema for updating TaskInstance to a deferred state."""
+
+ state: Annotated[
+ Literal[IntermediateTIState.DEFERRED],
+ # Specify a default in the schema, but not in code, so Pydantic marks
it as required.
+ WithJsonSchema(
+ {
+ "type": "string",
+ "enum": [IntermediateTIState.DEFERRED],
+ "default": IntermediateTIState.DEFERRED,
+ }
+ ),
+ ]
+
+ classpath: str
+ kwargs: dict[str, Any]
+ created_date: UtcDateTime
Review Comment:
This is how it looks in the Trigger class:
```
def __init__(
self,
classpath: str,
kwargs: dict[str, Any],
created_date: datetime.datetime | None = None,
) -> None:
super().__init__()
self.classpath = classpath
self.encrypted_kwargs = self._encrypt_kwargs(kwargs)
self.created_date = created_date or timezone.utcnow()
```
If we do not allow to override it, wont it be a regression from the past? We
can just leave out the field.
##########
airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -30,14 +30,16 @@
from airflow.api_fastapi.common.db.common import get_session
from airflow.api_fastapi.common.router import AirflowRouter
from airflow.api_fastapi.execution_api.datamodels.taskinstance import (
+ TIDeferredStatePayload,
TIEnterRunningPayload,
TIHeartbeatInfo,
TIStateUpdate,
TITerminalStatePayload,
)
+from airflow.models import Trigger
from airflow.models.taskinstance import TaskInstance as TI
from airflow.utils import timezone
-from airflow.utils.state import State
+from airflow.utils.state import State, TaskInstanceState
Review Comment:
Handled 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]