Skip to content

Commit

Permalink
add mising
Browse files Browse the repository at this point in the history
  • Loading branch information
jx2lee committed Dec 19, 2024
1 parent dafa7fe commit 823a6f0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
12 changes: 10 additions & 2 deletions airflow/api_fastapi/execution_api/datamodels/taskinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
class TIEnterRunningPayload(BaseModel):
"""Schema for updating TaskInstance to 'RUNNING' state with minimal required fields."""

model_config = ConfigDict(extra="forbid")

state: Annotated[
Literal[TIState.RUNNING],
# Specify a default in the schema, but not in code.
Expand All @@ -54,6 +56,8 @@ class TIEnterRunningPayload(BaseModel):
class TITerminalStatePayload(BaseModel):
"""Schema for updating TaskInstance to a terminal state (e.g., SUCCESS or FAILED)."""

model_config = ConfigDict(extra="forbid")

state: TerminalTIState

end_date: UtcDateTime
Expand All @@ -63,12 +67,16 @@ class TITerminalStatePayload(BaseModel):
class TITargetStatePayload(BaseModel):
"""Schema for updating TaskInstance to a target state, excluding terminal and running states."""

model_config = ConfigDict(extra="forbid")

state: IntermediateTIState


class TIDeferredStatePayload(BaseModel):
"""Schema for updating TaskInstance to a deferred state."""

model_config = ConfigDict(extra="forbid")

state: Annotated[
Literal[IntermediateTIState.DEFERRED],
# Specify a default in the schema, but not in code, so Pydantic marks it as required.
Expand Down Expand Up @@ -148,6 +156,8 @@ def ti_state_discriminator(v: dict[str, str] | BaseModel) -> str:
class TIHeartbeatInfo(BaseModel):
"""Schema for TaskInstance heartbeat endpoint."""

model_config = ConfigDict(extra="forbid")

hostname: str
pid: int

Expand Down Expand Up @@ -187,8 +197,6 @@ class DagRun(BaseModel):
class TIRunContext(BaseModel):
"""Response schema for TaskInstance run context."""

model_config = ConfigDict(extra="forbid")

dag_run: DagRun
"""DAG run information for the task instance."""

Expand Down
18 changes: 15 additions & 3 deletions task_sdk/src/airflow/sdk/api/datamodels/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ class TIDeferredStatePayload(BaseModel):
Schema for updating TaskInstance to a deferred state.
"""

model_config = ConfigDict(
extra="forbid",
)
state: Annotated[Literal["deferred"] | None, Field(title="State")] = "deferred"
classpath: Annotated[str, Field(title="Classpath")]
trigger_kwargs: Annotated[dict[str, Any] | None, Field(title="Trigger Kwargs")] = None
Expand All @@ -86,6 +89,9 @@ class TIEnterRunningPayload(BaseModel):
Schema for updating TaskInstance to 'RUNNING' state with minimal required fields.
"""

model_config = ConfigDict(
extra="forbid",
)
state: Annotated[Literal["running"] | None, Field(title="State")] = "running"
hostname: Annotated[str, Field(title="Hostname")]
unixname: Annotated[str, Field(title="Unixname")]
Expand All @@ -98,6 +104,9 @@ class TIHeartbeatInfo(BaseModel):
Schema for TaskInstance heartbeat endpoint.
"""

model_config = ConfigDict(
extra="forbid",
)
hostname: Annotated[str, Field(title="Hostname")]
pid: Annotated[int, Field(title="Pid")]

Expand All @@ -117,6 +126,9 @@ class TITargetStatePayload(BaseModel):
Schema for updating TaskInstance to a target state, excluding terminal and running states.
"""

model_config = ConfigDict(
extra="forbid",
)
state: IntermediateTIState


Expand Down Expand Up @@ -211,9 +223,6 @@ class TIRunContext(BaseModel):
Response schema for TaskInstance run context.
"""

model_config = ConfigDict(
extra="forbid",
)
dag_run: DagRun
variables: Annotated[list[VariableResponse] | None, Field(title="Variables")] = None
connections: Annotated[list[ConnectionResponse] | None, Field(title="Connections")] = None
Expand All @@ -224,5 +233,8 @@ class TITerminalStatePayload(BaseModel):
Schema for updating TaskInstance to a terminal state (e.g., SUCCESS or FAILED).
"""

model_config = ConfigDict(
extra="forbid",
)
state: TerminalTIState
end_date: Annotated[datetime, Field(title="End Date")]
2 changes: 1 addition & 1 deletion tests/api_fastapi/execution_api/routes/test_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_variable_get_from_db(self, client, session):
{"AIRFLOW_VAR_KEY1": "VALUE"},
)
def test_variable_get_from_env_var(self, client, session):
response = client.get("/execution/variables/key1")
response = client.get("/execution/variables/key1", params={"foo": "bar"})

assert response.status_code == 200
assert response.json() == {"key": "key1", "value": "VALUE"}
Expand Down

0 comments on commit 823a6f0

Please sign in to comment.