Skip to content

Commit 98a3d2d

Browse files
Lee-Wsuman-himanshu
authored andcommitted
fix(hitl): make the user model in HITLDetail consistent with airflow user model (apache#55463)
1 parent 2765550 commit 98a3d2d

36 files changed

Lines changed: 529 additions & 331 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c05cefbe080ed889ebe132a0285756db477ff28256bbc1e86da1e053873f6478
1+
e491b0c58188f06ab4696cc09c765413065069f90d78e27eb53fdac5e2e92c82

airflow-core/docs/img/airflow_erd.svg

Lines changed: 58 additions & 62 deletions
Loading

airflow-core/docs/tutorial/hitl.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ Approval or Rejection
9595
---------------------
9696

9797
A specialized form of option selection, which has only 'Approval' and 'Rejection' as options.
98+
You can also set the ``assigned_users`` to restrict the users allowed to respond for a HITL operator.
99+
It should be a list of user ids and user names (both needed) (e.g., ``[{"id": "1", "name": "user1"}, {"id": "2", "name": "user2"}]``.
100+
ONLY the users within this list will be allowed to respond.
98101

99102
.. exampleinclude:: /../../providers/standard/src/airflow/providers/standard/example_dags/example_hitl_operator.py
100103
:language: python

airflow-core/src/airflow/api_fastapi/common/parameters.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,27 +1022,28 @@ def _optional_boolean(value: bool | None) -> bool | None:
10221022
)
10231023
),
10241024
]
1025+
10251026
QueryHITLDetailRespondedUserIdFilter = Annotated[
10261027
FilterParam[list[str]],
10271028
Depends(
10281029
filter_param_factory(
1029-
HITLDetail.responded_user_id,
1030+
HITLDetail.responded_by_user_id,
10301031
list[str],
10311032
FilterOptionEnum.ANY_EQUAL,
10321033
default_factory=list,
1033-
filter_name="responded_user_id",
1034+
filter_name="responded_by_user_id",
10341035
)
10351036
),
10361037
]
10371038
QueryHITLDetailRespondedUserNameFilter = Annotated[
10381039
FilterParam[list[str]],
10391040
Depends(
10401041
filter_param_factory(
1041-
HITLDetail.responded_user_name,
1042+
HITLDetail.responded_by_user_name,
10421043
list[str],
10431044
FilterOptionEnum.ANY_EQUAL,
10441045
default_factory=list,
1045-
filter_name="responded_user_name",
1046+
filter_name="responded_by_user_name",
10461047
)
10471048
),
10481049
]

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,19 @@ class UpdateHITLDetailPayload(BaseModel):
3737
class HITLDetailResponse(BaseModel):
3838
"""Response of updating a Human-in-the-loop detail."""
3939

40-
responded_user_id: str
41-
responded_user_name: str
40+
responded_by: HITLUser
4241
response_at: datetime
4342
chosen_options: list[str] = Field(min_length=1)
4443
params_input: Mapping = Field(default_factory=dict)
4544

4645

46+
class HITLUser(BaseModel):
47+
"""Schema for a Human-in-the-loop users."""
48+
49+
id: str
50+
name: str
51+
52+
4753
class HITLDetail(BaseModel):
4854
"""Schema for Human-in-the-loop detail."""
4955

@@ -56,11 +62,10 @@ class HITLDetail(BaseModel):
5662
defaults: list[str] | None = None
5763
multiple: bool = False
5864
params: dict[str, Any] = Field(default_factory=dict)
59-
respondents: list[str] | None = None
65+
assigned_users: list[HITLUser] = Field(default_factory=list)
6066

6167
# Response Content Detail
62-
responded_user_id: str | None = None
63-
responded_user_name: str | None = None
68+
responded_by_user: HITLUser | None = None
6469
response_at: datetime | None = None
6570
chosen_options: list[str] | None = None
6671
params_input: dict[str, Any] = Field(default_factory=dict)

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

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,23 +1994,15 @@ components:
19941994
additionalProperties: true
19951995
type: object
19961996
title: Params
1997-
respondents:
1998-
anyOf:
1999-
- items:
2000-
type: string
2001-
type: array
2002-
- type: 'null'
2003-
title: Respondents
2004-
responded_user_id:
2005-
anyOf:
2006-
- type: string
2007-
- type: 'null'
2008-
title: Responded User Id
2009-
responded_user_name:
1997+
assigned_users:
1998+
items:
1999+
$ref: '#/components/schemas/HITLUser'
2000+
type: array
2001+
title: Assigned Users
2002+
responded_by_user:
20102003
anyOf:
2011-
- type: string
2004+
- $ref: '#/components/schemas/HITLUser'
20122005
- type: 'null'
2013-
title: Responded User Name
20142006
response_at:
20152007
anyOf:
20162008
- type: string
@@ -2039,6 +2031,20 @@ components:
20392031
- subject
20402032
title: HITLDetail
20412033
description: Schema for Human-in-the-loop detail.
2034+
HITLUser:
2035+
properties:
2036+
id:
2037+
type: string
2038+
title: Id
2039+
name:
2040+
type: string
2041+
title: Name
2042+
type: object
2043+
required:
2044+
- id
2045+
- name
2046+
title: HITLUser
2047+
description: Schema for a Human-in-the-loop users.
20422048
HTTPExceptionResponse:
20432049
properties:
20442050
detail:

0 commit comments

Comments
 (0)