-
Notifications
You must be signed in to change notification settings - Fork 17.4k
Improve speed to run airflow by 6x
#21438
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
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 |
|---|---|---|
|
|
@@ -18,10 +18,9 @@ | |
| import logging | ||
| from contextlib import suppress | ||
| from enum import Enum, unique | ||
| from typing import Optional, Tuple, Type | ||
| from typing import TYPE_CHECKING, Optional, Tuple, Type | ||
|
|
||
| from airflow.exceptions import AirflowConfigException | ||
| from airflow.executors.base_executor import BaseExecutor | ||
| from airflow.executors.executor_constants import ( | ||
| CELERY_EXECUTOR, | ||
| CELERY_KUBERNETES_EXECUTOR, | ||
|
|
@@ -35,6 +34,9 @@ | |
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
| if TYPE_CHECKING: | ||
| from airflow.executors.base_executor import BaseExecutor | ||
|
Member
Author
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. By moving this here it prevents loading all the models and saves a goodly chunk of time.
Member
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. Fantastic! |
||
|
|
||
|
|
||
| @unique | ||
| class ConnectorSource(Enum): | ||
|
|
@@ -48,7 +50,7 @@ class ConnectorSource(Enum): | |
| class ExecutorLoader: | ||
| """Keeps constants for all the currently available executors.""" | ||
|
|
||
| _default_executor: Optional[BaseExecutor] = None | ||
| _default_executor: Optional["BaseExecutor"] = None | ||
| executors = { | ||
| LOCAL_EXECUTOR: 'airflow.executors.local_executor.LocalExecutor', | ||
| SEQUENTIAL_EXECUTOR: 'airflow.executors.sequential_executor.SequentialExecutor', | ||
|
|
@@ -60,7 +62,7 @@ class ExecutorLoader: | |
| } | ||
|
|
||
| @classmethod | ||
| def get_default_executor(cls) -> BaseExecutor: | ||
| def get_default_executor(cls) -> "BaseExecutor": | ||
| """Creates a new instance of the configured executor if none exists and returns it""" | ||
| if cls._default_executor is not None: | ||
| return cls._default_executor | ||
|
|
@@ -74,7 +76,7 @@ def get_default_executor(cls) -> BaseExecutor: | |
| return cls._default_executor | ||
|
|
||
| @classmethod | ||
| def load_executor(cls, executor_name: str) -> BaseExecutor: | ||
| def load_executor(cls, executor_name: str) -> "BaseExecutor": | ||
| """ | ||
| Loads the executor. | ||
|
|
||
|
|
@@ -101,7 +103,7 @@ def load_executor(cls, executor_name: str) -> BaseExecutor: | |
| return executor_cls() | ||
|
|
||
| @classmethod | ||
| def import_executor_cls(cls, executor_name: str) -> Tuple[Type[BaseExecutor], ConnectorSource]: | ||
| def import_executor_cls(cls, executor_name: str) -> Tuple[Type["BaseExecutor"], ConnectorSource]: | ||
| """ | ||
| Imports the executor class. | ||
|
|
||
|
|
@@ -127,7 +129,7 @@ def import_executor_cls(cls, executor_name: str) -> Tuple[Type[BaseExecutor], Co | |
| return import_string(executor_name), ConnectorSource.CUSTOM_PATH | ||
|
|
||
| @classmethod | ||
| def __load_celery_kubernetes_executor(cls) -> BaseExecutor: | ||
| def __load_celery_kubernetes_executor(cls) -> "BaseExecutor": | ||
| """:return: an instance of CeleryKubernetesExecutor""" | ||
| celery_executor = import_string(cls.executors[CELERY_EXECUTOR])() | ||
| kubernetes_executor = import_string(cls.executors[KUBERNETES_EXECUTOR])() | ||
|
|
||
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling that this might break something. Lets see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Let's see :)