Skip to content

Commit f2ecf32

Browse files
Lee-Wsuman-himanshu
authored andcommitted
Add HITLDetail.created_at (apache#55525)
1 parent b09f5f2 commit f2ecf32

19 files changed

Lines changed: 220 additions & 73 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
35e9e07930e138664fb6ff23bc299567a88946734630d84f3d7d95deacf2f4b8
1+
35b8a7f30e44075373199a53e6634693f4254287a9ecff0582d9ae926fc7aaae

airflow-core/docs/img/airflow_erd.svg

Lines changed: 63 additions & 58 deletions
Loading

airflow-core/src/airflow/api_fastapi/core_api/datamodels/hitl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class HITLDetail(BaseModel):
6363
multiple: bool = False
6464
params: dict[str, Any] = Field(default_factory=dict)
6565
assigned_users: list[HITLUser] = Field(default_factory=list)
66+
created_at: datetime
6667

6768
# Response Content Detail
6869
responded_by_user: HITLUser | None = None

airflow-core/src/airflow/api_fastapi/core_api/openapi/_private_ui.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,6 +1999,10 @@ components:
19991999
$ref: '#/components/schemas/HITLUser'
20002000
type: array
20012001
title: Assigned Users
2002+
created_at:
2003+
type: string
2004+
format: date-time
2005+
title: Created At
20022006
responded_by_user:
20032007
anyOf:
20042008
- $ref: '#/components/schemas/HITLUser'
@@ -2029,6 +2033,7 @@ components:
20292033
- task_instance
20302034
- options
20312035
- subject
2036+
- created_at
20322037
title: HITLDetail
20332038
description: Schema for Human-in-the-loop detail.
20342039
HITLUser:

airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8264,6 +8264,42 @@ paths:
82648264
title: Body Search
82658265
description: "SQL LIKE expression \u2014 use `%` / `_` wildcards (e.g. `%customer_%`).\
82668266
\ Regular expressions are **not** supported."
8267+
- name: created_at_gte
8268+
in: query
8269+
required: false
8270+
schema:
8271+
anyOf:
8272+
- type: string
8273+
format: date-time
8274+
- type: 'null'
8275+
title: Created At Gte
8276+
- name: created_at_gt
8277+
in: query
8278+
required: false
8279+
schema:
8280+
anyOf:
8281+
- type: string
8282+
format: date-time
8283+
- type: 'null'
8284+
title: Created At Gt
8285+
- name: created_at_lte
8286+
in: query
8287+
required: false
8288+
schema:
8289+
anyOf:
8290+
- type: string
8291+
format: date-time
8292+
- type: 'null'
8293+
title: Created At Lte
8294+
- name: created_at_lt
8295+
in: query
8296+
required: false
8297+
schema:
8298+
anyOf:
8299+
- type: string
8300+
format: date-time
8301+
- type: 'null'
8302+
title: Created At Lt
82678303
responses:
82688304
'200':
82698305
description: Successful Response
@@ -10890,6 +10926,10 @@ components:
1089010926
$ref: '#/components/schemas/HITLUser'
1089110927
type: array
1089210928
title: Assigned Users
10929+
created_at:
10930+
type: string
10931+
format: date-time
10932+
title: Created At
1089310933
responded_by_user:
1089410934
anyOf:
1089510935
- $ref: '#/components/schemas/HITLUser'
@@ -10920,6 +10960,7 @@ components:
1092010960
- task_instance
1092110961
- options
1092210962
- subject
10963+
- created_at
1092310964
title: HITLDetail
1092410965
description: Schema for Human-in-the-loop detail.
1092510966
HITLDetailCollection:

airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
QueryLimit,
3939
QueryOffset,
4040
QueryTIStateFilter,
41+
RangeFilter,
4142
SortParam,
43+
datetime_range_filter_factory,
4244
)
4345
from airflow.api_fastapi.common.router import AirflowRouter
4446
from airflow.api_fastapi.core_api.datamodels.hitl import (
@@ -209,6 +211,7 @@ def get_hitl_details(
209211
"ti_id",
210212
"subject",
211213
"responded_at",
214+
"created_at",
212215
],
213216
model=HITLDetailModel,
214217
to_replace={
@@ -234,6 +237,7 @@ def get_hitl_details(
234237
responded_user_name: QueryHITLDetailRespondedUserNameFilter,
235238
subject_patten: QueryHITLDetailSubjectSearch,
236239
body_patten: QueryHITLDetailBodySearch,
240+
created_at: Annotated[RangeFilter, Depends(datetime_range_filter_factory("created_at", HITLDetailModel))],
237241
) -> HITLDetailCollection:
238242
"""Get Human-in-the-loop details."""
239243
query = (
@@ -265,6 +269,7 @@ def get_hitl_details(
265269
responded_user_name,
266270
subject_patten,
267271
body_patten,
272+
created_at,
268273
],
269274
offset=offset,
270275
limit=limit,

airflow-core/src/airflow/migrations/versions/0076_3_1_0_add_human_in_the_loop_response.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from sqlalchemy import Boolean, Column, ForeignKeyConstraint, String, Text
3333
from sqlalchemy.dialects import postgresql
3434

35+
from airflow._shared.timezones import timezone
3536
from airflow.settings import json
3637
from airflow.utils.sqlalchemy import UtcDateTime
3738

@@ -60,6 +61,7 @@ def upgrade():
6061
Column("multiple", Boolean, unique=False, default=False),
6162
Column("params", sqlalchemy_jsonfield.JSONField(json=json), nullable=False, default={}),
6263
Column("assignees", sqlalchemy_jsonfield.JSONField(json=json), nullable=True),
64+
Column("created_at", UtcDateTime(timezone=True), nullable=False, default=timezone.utcnow),
6365
Column("responded_at", UtcDateTime, nullable=True),
6466
Column("responded_by", sqlalchemy_jsonfield.JSONField(json=json), nullable=True),
6567
Column("chosen_options", sqlalchemy_jsonfield.JSONField(json=json), nullable=True),

airflow-core/src/airflow/models/hitl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from sqlalchemy.orm import relationship
2727
from sqlalchemy.sql.functions import FunctionElement
2828

29+
from airflow._shared.timezones import timezone
2930
from airflow.models.base import Base
3031
from airflow.settings import json
3132
from airflow.utils.sqlalchemy import UtcDateTime
@@ -97,6 +98,7 @@ class HITLDetail(Base):
9798
multiple = Column(Boolean, unique=False, default=False)
9899
params = Column(sqlalchemy_jsonfield.JSONField(json=json), nullable=False, default={})
99100
assignees = Column(sqlalchemy_jsonfield.JSONField(json=json), nullable=True)
101+
created_at = Column(UtcDateTime, default=timezone.utcnow, nullable=False)
100102

101103
# Response Content Detail
102104
responded_at = Column(UtcDateTime, nullable=True)

0 commit comments

Comments
 (0)