-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Add Human-in-the-loop logic to core Airflow and implement HITLOperator, ApprovalOperator, HITLEntryOperator in standard provider
#52868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
92b760a
feat: AIP-90 PoC
Lee-W 79752b9
feat(hitl): move hitl execution api to core
Lee-W e356520
feat(hitl): move models
Lee-W 633b74b
feat(hitl): move core_api from provider to core
Lee-W c6fd458
feat(hitl): add migration files
Lee-W 78cbc3c
fix: fix ci issue
Lee-W cae9039
build: rebuild frontend
Lee-W ae41a3a
fix(hitl): generate datamodel
Lee-W 48e0eeb
fix(hitl): add HITL module to models
Lee-W 939d288
feat(hitl): add multiple support
Lee-W c75afe4
test(hitl): improve supervisor.handle_request
Lee-W 2d57bce
test(hitl): add execution_time test cases
Lee-W c70d69d
test(hitl): add test cases to public api
Lee-W 21cd2fb
refactor(hitl): replace ImportError with AirflowOptionalProviderFeatu…
Lee-W 2a758f2
refactor(hitl): remove unnecessay directories
Lee-W 8c2a59f
test(hitl): add test cases to execution api
Lee-W 4e5696a
test(hitl): add test cases to operators
Lee-W 63f850c
style: fix mypy warning
Lee-W b06e181
ci: fix ci errors
Lee-W ed04ffa
feat(hitl): add fk constraint
Lee-W fcd7c3d
feat(hitl): set params as ParamsDict
Lee-W 8ef4cd9
docs(hitl_operator): update body description
Lee-W a0b30f8
feat(hitl): rename hitl-responses as hitl-details
Lee-W 2144114
feat(hitl): rename response_content as chosen_options
Lee-W 63978db
feat(hitl): rename default as defaults
Lee-W 37ff01c
feat(hitl): rewrite public api to fit frontend's need
Lee-W 22b23c5
style(hitl): improve test typing
Lee-W c5fe122
test(hitl): add mapped test cases
Lee-W 570350d
feat(hitl): merge termination operator into approval operators
Lee-W 43ab982
feat(hitl): allow timeout without default
Lee-W File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| e0de73aab81a28995b99be21dd25c8ca31c4e0f4a5a0a26df8aff412e5067fd5 | ||
| 2e49ab99fe1076b0f3f22a52b9ee37eeb7fc20a5a043ea504cc26022f4315277 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
airflow-core/src/airflow/api_fastapi/core_api/datamodels/hitl.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Mapping | ||
| from datetime import datetime | ||
| from typing import Any | ||
|
|
||
| from pydantic import Field, field_validator | ||
|
|
||
| from airflow.api_fastapi.core_api.base import BaseModel | ||
| from airflow.sdk import Param | ||
|
|
||
|
|
||
| class UpdateHITLDetailPayload(BaseModel): | ||
| """Schema for updating the content of a Human-in-the-loop detail.""" | ||
|
|
||
| chosen_options: list[str] | ||
| params_input: Mapping = Field(default_factory=dict) | ||
|
|
||
|
|
||
| class HITLDetailResponse(BaseModel): | ||
| """Response of updating a Human-in-the-loop detail.""" | ||
|
|
||
| user_id: str | ||
| response_at: datetime | ||
| chosen_options: list[str] | ||
| params_input: Mapping = Field(default_factory=dict) | ||
|
|
||
|
|
||
| class HITLDetail(BaseModel): | ||
| """Schema for Human-in-the-loop detail.""" | ||
|
|
||
| ti_id: str | ||
|
|
||
| # User Request Detail | ||
| options: list[str] | ||
| subject: str | ||
| body: str | None = None | ||
| defaults: list[str] | None = None | ||
| multiple: bool = False | ||
| params: dict[str, Any] = Field(default_factory=dict) | ||
|
|
||
| # Response Content Detail | ||
| user_id: str | None = None | ||
| response_at: datetime | None = None | ||
| chosen_options: list[str] | None = None | ||
| params_input: dict[str, Any] = Field(default_factory=dict) | ||
|
|
||
| response_received: bool = False | ||
|
|
||
| @field_validator("params", mode="before") | ||
| @classmethod | ||
| def get_params(cls, params: dict[str, Any]) -> dict[str, Any]: | ||
| """Convert params attribute to dict representation.""" | ||
| return {k: v.dump() if isinstance(v, Param) else v for k, v in params.items()} | ||
|
|
||
|
|
||
| class HITLDetailCollection(BaseModel): | ||
| """Schema for a collection of Human-in-the-loop details.""" | ||
|
|
||
| hitl_details: list[HITLDetail] | ||
| total_entries: int | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.