FrankYang0529 commented on code in PR #72858:
URL: https://github.com/apache/airflow/pull/72858#discussion_r3979654240
##########
airflow-core/src/airflow/cli/cli_parser.py:
##########
@@ -99,40 +132,48 @@
component="executors",
not_defined_cli_dict=str(executors_not_defined_cli)
)
)
- from airflow.executors.executor_loader import ExecutorLoader
-
- for executor_name in
ExecutorLoader.get_executor_names(validate_teams=False):
- # Skip if the executor already has CLI commands defined via
the 'cli' section in provider.yaml
- if executor_name.module_path not in executors_not_defined_cli:
- log.debug(
- "Skipping loading for '%s' as it is defined in 'cli'
section.",
- executor_name.module_path,
- )
- continue
-
- try:
- executor, _ =
ExecutorLoader.import_executor_cls(executor_name)
- airflow_commands.extend(executor.get_cli_commands())
- except Exception:
- log.exception("Failed to load CLI commands from executor:
%s", executor_name)
- log.error(
- "Ensure all dependencies are met and try again. If
using a Celery based executor install "
- "a 3.3.0+ version of the Celery provider. If using a
Kubernetes executor, install a "
- "7.4.0+ version of the CNCF provider"
+ executors_defined_cli = {
Review Comment:
I agree these are two different changes and fix the docstring.
I tried keeping the import lazy, and the `executor_loader` case still fails.
The executor block now runs on every start to look for custom classes, so the
import inside it runs during the test. That case only passes when
`AIRFLOW_PACKAGE_NAME` is set.
A lazy import also would not guard against a real cost. `executor_loader`
was already in `sys.modules` before `cli_parser` ran, including with
`AIRFLOW_PACKAGE_NAME` set. The first import comes from `import airflow`
itself, through `settings`, `logging_config` and `file_task_handler`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]