Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,44 @@ def validate_new_state(cls, ns: str | None) -> str:
return ns


class PatchTaskInstancesBody(StrictBaseModel):
"""Request body for Patch Task Instances endpoint."""

task_ids: list[str | tuple[str, int]] = Field(
description="A list of `task_id` or [`task_id`, `map_index`]. "
"If only the `task_id` is provided for a mapped task, all of its map indices will be targeted.",
)
new_state: TaskInstanceState | None = None
note: Annotated[str, StringConstraints(max_length=1000)] | None = None
include_upstream: bool = False
include_downstream: bool = False
include_future: bool = False
include_past: bool = False

@field_validator("new_state", mode="before")
@classmethod
def validate_new_state(cls, ns: str | None) -> str:
"""Validate new_state."""
valid_states = [
vs.name.lower()
for vs in (TaskInstanceState.SUCCESS, TaskInstanceState.FAILED, TaskInstanceState.SKIPPED)
]
if ns is None:
raise ValueError("'new_state' should not be empty")
ns = ns.lower()
if ns not in valid_states:
raise ValueError(f"'{ns}' is not one of {valid_states}")
return ns

@model_validator(mode="before")
@classmethod
def validate_model(cls, data: Any) -> Any:
"""Validate patch task instances form."""
if isinstance(data.get("task_ids"), list) and len(data.get("task_ids")) < 1:
raise ValidationError("task_ids list should have at least 1 element.")
return data


class BulkTaskInstanceBody(PatchTaskInstanceBody, StrictBaseModel):
"""Request body for bulk update, and delete task instances."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6979,7 +6979,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/BulkResponse'
$ref: '#/components/schemas/TaskInstanceCollectionResponse'
'401':
content:
application/json:
Expand Down Expand Up @@ -7444,6 +7444,60 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/dry_run:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't use the bulk task instance endpoint.

patch:
tags:
- Task Instance
summary: Bulk Task Instances Dry Run
description: Bulk update, and delete task instances dry run.
operationId: bulk_task_instances_dry_run
security:
- OAuth2PasswordBearer: []
- HTTPBearer: []
parameters:
- name: dag_id
in: path
required: true
schema:
type: string
title: Dag Id
- name: dag_run_id
in: path
required: true
schema:
type: string
title: Dag Run Id
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BulkBody_BulkTaskInstanceBody_'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/TaskInstanceCollectionResponse'
'401':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPExceptionResponse'
description: Unauthorized
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPExceptionResponse'
description: Forbidden
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/api/v2/dags/{dag_id}/tasks:
get:
tags:
Expand Down
Loading
Loading