Skip to content

Commit

Permalink
Finalise the endpoint (=other than dynamically created tasks and addr…
Browse files Browse the repository at this point in the history
…ess comments
  • Loading branch information
bugraoz93 committed Nov 27, 2024
1 parent cb0d6c0 commit 597fed2
Show file tree
Hide file tree
Showing 10 changed files with 425 additions and 162 deletions.
26 changes: 4 additions & 22 deletions airflow/api_fastapi/common/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,38 +159,21 @@ def depends(self, dag_run_ids: list[str] = Query(None)) -> DagRunIdsFilter:
return self.set_value(dag_run_ids)


class DagRunRunTypesFilter(BaseParam[list[str]]):
class DagRunRunTypesFilter(BaseParam[Optional[list[str]]]):
"""Filter on dag run run_types."""

def __init__(self, model: Base, value: list[str] | None = None, skip_none: bool = True) -> None:
def __init__(self, value: list[str] | None = None, skip_none: bool = True) -> None:
super().__init__(value, skip_none)
self.model = model

def to_orm(self, select: Select) -> Select:
if self.value and self.skip_none:
return select.where(self.model.run_type.in_(self.value))
return select.where(DagRun.run_type.in_(self.value))
return select

def depends(self, run_types: list[str] = Query(None)) -> DagRunRunTypesFilter:
return self.set_value(run_types)


class DagRunRunStatesFilter(BaseParam[list[str]]):
"""Filter on dag run_states."""

def __init__(self, model: Base, value: list[str] | None = None, skip_none: bool = True) -> None:
super().__init__(value, skip_none)
self.model = model

def to_orm(self, select: Select) -> Select:
if self.value and self.skip_none:
return select.where(self.model.state.in_(self.value))
return select

def depends(self, run_states: list[str] = Query(None)) -> DagRunRunStatesFilter:
return self.set_value(run_states)


class TaskIdsFilter(BaseParam[list[str]]):
"""Filter on task ids."""

Expand Down Expand Up @@ -786,8 +769,7 @@ def depends_float(
QueryLastDagRunStateFilter = Annotated[_LastDagRunStateFilter, Depends(_LastDagRunStateFilter().depends)]
QueryDagIdsFilter = Annotated[DagIdsFilter, Depends(DagIdsFilter(DagRun).depends)]
QueryDagRunStateFilter = Annotated[DagRunStateFilter, Depends(DagRunStateFilter().depends)]
QueryDagRunRunTypesFilter = Annotated[DagRunRunTypesFilter, Depends(DagRunRunTypesFilter(DagRun).depends)]
QueryDagRunRunStatesFilter = Annotated[DagRunRunStatesFilter, Depends(DagRunRunStatesFilter(DagRun).depends)]
QueryDagRunRunTypesFilter = Annotated[DagRunRunTypesFilter, Depends(DagRunRunTypesFilter().depends)]

# DAGWarning
QueryDagIdInDagWarningFilter = Annotated[_DagIdFilter, Depends(_DagIdFilter(DagWarning.dag_id).depends)]
Expand Down
12 changes: 0 additions & 12 deletions airflow/api_fastapi/core_api/datamodels/ui/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@
from pydantic import BaseModel


class GridTaskInstance(BaseModel):
"""Task Instance model for the Grid UI."""

run_id: str
task_id: str
try_number: int
start_date: datetime | None
end_date: datetime | None
queued_dttm: datetime | None
state: str | None


class GridTaskInstanceSummary(BaseModel):
"""Task Instance Summary model for the Grid UI."""

Expand Down
14 changes: 8 additions & 6 deletions airflow/api_fastapi/core_api/openapi/v1-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/HTTPExceptionResponse'
/ui/grid/:
/ui/grid/{dag_id}:
get:
tags:
- Grid
Expand All @@ -203,16 +203,18 @@ paths:
operationId: grid_data
parameters:
- name: dag_id
in: query
in: path
required: true
schema:
type: string
title: Dag Id
- name: base_date
in: query
required: true
required: false
schema:
type: string
anyOf:
- type: string
- type: 'null'
title: Base Date
- name: root
in: query
Expand Down Expand Up @@ -244,14 +246,14 @@ paths:
items:
type: string
title: Run Types
- name: run_states
- name: state
in: query
required: false
schema:
type: array
items:
type: string
title: Run States
title: State
- name: offset
in: query
required: false
Expand Down
Loading

0 comments on commit 597fed2

Please sign in to comment.