-
Notifications
You must be signed in to change notification settings - Fork 17k
Add ExecuteCallback support to Edge Executor #63498
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
base: main
Are you sure you want to change the base?
Changes from all commits
aa6e13a
6b913d0
70d6b5f
75abf7d
a454837
0c1e21e
260425f
a30fd0b
65c0e31
8e30e07
262d333
2fec49c
218b770
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # 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 typing import TYPE_CHECKING, TypeAlias, TypeGuard | ||
|
|
||
| from airflow.executors.workloads import ExecuteTask | ||
| from airflow.providers.edge3.version_compat import AIRFLOW_V_3_3_PLUS | ||
|
|
||
| if TYPE_CHECKING: | ||
| from airflow.executors import workloads | ||
| from airflow.executors.workloads import ExecuteCallback | ||
|
|
||
| if not AIRFLOW_V_3_3_PLUS: | ||
| ExecuteTypeBody: TypeAlias = ExecuteTask | ||
| else: | ||
| from airflow.executors.workloads import ExecutorWorkload | ||
|
|
||
| ExecuteTypeBody: TypeAlias = ExecutorWorkload # type: ignore[no-redef,misc] | ||
|
|
||
|
|
||
| def is_callback_execute(workload: workloads.All) -> TypeGuard[ExecuteCallback]: | ||
| if AIRFLOW_V_3_3_PLUS: | ||
| from airflow.executors.workloads import ExecuteCallback | ||
|
|
||
| return isinstance(workload, ExecuteCallback) | ||
| return False | ||
|
|
||
|
|
||
| # This is the key used to identify execute_callback jobs. | ||
| # Changing this value may break compatibility with existing data in the edge_job table. | ||
| EXECUTE_CALLBACK_TAG = "ExecuteCallback" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,9 +25,9 @@ | |
| from fastapi import Path | ||
| from pydantic import BaseModel, Field | ||
|
|
||
| from airflow.executors.workloads import ExecuteTask # noqa: TCH001 | ||
| from airflow.providers.common.compat.sdk import TaskInstanceKey | ||
| from airflow.providers.edge3.models.edge_worker import EdgeWorkerState # noqa: TCH001 | ||
| from airflow.providers.edge3.models.types import ExecuteTypeBody # noqa: TCH001 | ||
|
|
||
|
|
||
| class WorkerApiDocs: | ||
|
|
@@ -91,7 +91,7 @@ class EdgeJobFetched(EdgeJobBase): | |
| """Job that is to be executed on the edge worker.""" | ||
|
|
||
| command: Annotated[ | ||
| ExecuteTask, | ||
| ExecuteTypeBody, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, maybe coming a bit late during second pass: So far the API was always backwards compatible, means if you have a Edge worker with a previous version running it would happily continue to run and softly "drain" if there is a provider or Airflow core version mis-match. Now here the return type for job fetching changes, means if the worker would attempt to fetch a job with an old version, the job would be assigned but the worker (probably?) fails in de-serializing the content and fails. Probably before draining. Have you tested this and how does it behave? If this is a problem can we make it somehow compatible or make a parallel endpoint such that it is not failing on old clients until they drain and jobs are not pulled and never executed? |
||
| Field( | ||
| title="Command", | ||
| description="Command line to use to execute the job in Airflow", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.