-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Introduce generic Callbacks to support running callbacks on executors #54796
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
15 commits
Select commit
Hold shift + click to select a range
4cde949
Introduce generic Callbacks
ramitkataria 5ec5076
Add DB migration
ramitkataria ebdea91
Revert the last 2 commits
ramitkataria 6a9622e
Merge branch 'main' into ramitkataria/callback-table
ramitkataria 3acb8f9
Introduce generic Callbacks
ramitkataria 52dfdd7
Merge branch 'main' into ramitkataria/callback-table
ramitkataria e8f8efb
Refactor workloads to reduce code duplication
ramitkataria de1198a
Make fetch_method required in ExecutorCallback constructor
ramitkataria 32f15bc
Merge branch 'main' into ramitkataria/callback-table
ramitkataria 6ed4195
Minor change of order in autogenerated edge3 api yaml because of refa…
ramitkataria cb03b13
PR fixes
ramitkataria ceb99f4
Merge branch 'main' into ramitkataria/callback-table
ramitkataria 288daf1
Make fetch method non nullable
ramitkataria 0be971f
Merge branch 'main' into ramitkataria/callback-table
ramitkataria 84289d0
Merge branch 'main' into ramitkataria/callback-table
ramitkataria 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
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 @@ | ||
| 62f6d0409a5328d95254ca95018161f705f751b24768f0f4b86a736766143959 | ||
| 87f70348b8f566de55d6e9704925ca89359d92d6045f20e37f17e15989067f76 |
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
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
101 changes: 101 additions & 0 deletions
101
airflow-core/src/airflow/migrations/versions/0091_3_2_0_restructure_callback_table.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,101 @@ | ||
| # | ||
| # 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. | ||
|
|
||
| """ | ||
| Restructure callback table. | ||
|
|
||
| Revision ID: b87d2135fa50 | ||
| Revises: 69ddce9a7247 | ||
| Create Date: 2025-09-10 13:58:23.435028 | ||
|
|
||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
| from sqlalchemy_utils import UUIDType | ||
|
|
||
| import airflow | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "b87d2135fa50" | ||
| down_revision = "69ddce9a7247" | ||
| branch_labels = None | ||
| depends_on = None | ||
| airflow_version = "3.2.0" | ||
|
|
||
|
|
||
| def upgrade(): | ||
| """ | ||
| Restructure callback table. | ||
|
|
||
| Add/drop/modify columns, create foreign key for trigger and rename the table name. | ||
| """ | ||
| # Drop all rows. this will only affect users who have Dag Processor callbacks in non-terminal states | ||
| # during migration. | ||
| op.execute("DELETE FROM callback_request") | ||
| # TODO: migrate existing rows for pending DagProcessor callbacks | ||
ramitkataria marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| op.rename_table("callback_request", "callback") | ||
| with op.batch_alter_table("callback", schema=None) as batch_op: | ||
| batch_op.add_column(sa.Column("type", sa.String(length=20), nullable=False)) | ||
| batch_op.add_column(sa.Column("fetch_method", sa.String(length=20), nullable=False)) | ||
| batch_op.add_column(sa.Column("data", airflow.utils.sqlalchemy.ExtendedJSON(), nullable=True)) | ||
| batch_op.add_column(sa.Column("state", sa.String(length=10), nullable=True)) | ||
| batch_op.add_column(sa.Column("output", sa.Text(), nullable=True)) | ||
| batch_op.add_column(sa.Column("trigger_id", sa.Integer(), nullable=True)) | ||
| batch_op.create_foreign_key(batch_op.f("callback_trigger_id_fkey"), "trigger", ["trigger_id"], ["id"]) | ||
|
|
||
| # Replace INTEGER id with UUID id | ||
| batch_op.drop_column("id") | ||
| batch_op.add_column(sa.Column("id", UUIDType(binary=False), nullable=False, primary_key=True)) | ||
|
|
||
| batch_op.drop_column("callback_data") | ||
| batch_op.drop_column("callback_type") | ||
|
|
||
|
|
||
| def downgrade(): | ||
| """ | ||
| Unapply the callback table restructure. | ||
|
|
||
| Add/drop/modify columns, create foreign key for trigger and rename the table name. | ||
| """ | ||
| op.execute("DELETE FROM callback") # Drop all rows. See comment in upgrade(). | ||
|
|
||
| with op.batch_alter_table("callback", schema=None) as batch_op: | ||
| batch_op.add_column(sa.Column("callback_type", sa.String(length=20), nullable=False)) | ||
| batch_op.add_column( | ||
| sa.Column("callback_data", airflow.utils.sqlalchemy.ExtendedJSON(), nullable=False) | ||
| ) | ||
|
|
||
| # Replace UUID id with INTEGER id | ||
| batch_op.drop_column("id") | ||
| batch_op.add_column(sa.Column("id", sa.INTEGER(), nullable=False, autoincrement=True)) | ||
| # MySQL requires the primary key constraint to be created separately when autoincrement=True | ||
| batch_op.create_primary_key("callback_request_pkey", ["id"]) | ||
|
|
||
| batch_op.drop_constraint(batch_op.f("callback_trigger_id_fkey"), type_="foreignkey") | ||
| batch_op.drop_column("trigger_id") | ||
| batch_op.drop_column("output") | ||
| batch_op.drop_column("state") | ||
| batch_op.drop_column("data") | ||
| batch_op.drop_column("fetch_method") | ||
| batch_op.drop_column("type") | ||
|
|
||
| op.rename_table("callback", "callback_request") | ||
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
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.