From 6077904d2a3ab7a330460246a5b399efc0f7c958 Mon Sep 17 00:00:00 2001 From: Jed Cunningham Date: Mon, 24 Mar 2025 21:07:47 -0600 Subject: [PATCH 1/3] AIP-81: Flatten CLI commands With the remote commands being added to a separate distribution, we no longer need to distinguish between local and remote commands in core - they are all local commands! --- .github/CODEOWNERS | 2 +- .github/boring-cyborg.yml | 8 +- .../airflow/api_fastapi/gunicorn_config.py | 2 +- airflow-core/src/airflow/cli/cli_config.py | 178 +++++++++--------- .../api_server_command.py | 0 .../{remote_commands => }/asset_command.py | 0 .../{remote_commands => }/backfill_command.py | 0 .../cheat_sheet_command.py | 0 .../{remote_commands => }/config_command.py | 0 .../connection_command.py | 0 .../{local_commands => }/daemon_utils.py | 0 .../{remote_commands => }/dag_command.py | 0 .../dag_processor_command.py | 2 +- .../{local_commands => }/db_command.py | 0 .../{local_commands => }/info_command.py | 0 .../{remote_commands => }/jobs_command.py | 0 .../{local_commands => }/kerberos_command.py | 2 +- .../cli/commands/local_commands/__init__.py | 16 -- .../{local_commands => }/plugins_command.py | 0 .../{remote_commands => }/pool_command.py | 0 .../{remote_commands => }/provider_command.py | 0 .../cli/commands/remote_commands/__init__.py | 16 -- .../rotate_fernet_key_command.py | 0 .../{local_commands => }/scheduler_command.py | 2 +- .../standalone_command.py | 0 .../{remote_commands => }/task_command.py | 0 .../{local_commands => }/triggerer_command.py | 2 +- .../{remote_commands => }/variable_command.py | 0 .../{remote_commands => }/version_command.py | 0 .../core_api/routes/public/test_job.py | 2 +- .../cli/commands/local_commands/__init__.py | 16 -- .../cli/commands/remote_commands/__init__.py | 16 -- .../test_api_server_command.py | 2 +- .../test_asset_command.py | 2 +- .../test_backfill_command.py | 10 +- .../test_cheat_sheet_command.py | 0 .../test_config_command.py | 14 +- .../test_connection_command.py | 4 +- .../{remote_commands => }/test_dag_command.py | 30 ++- .../test_dag_processor_command.py | 6 +- .../{local_commands => }/test_db_command.py | 70 +++---- .../{local_commands => }/test_info_command.py | 4 +- .../test_jobs_command.py | 2 +- .../test_kerberos_command.py | 18 +- .../unit/cli/commands/test_legacy_commands.py | 2 +- .../test_plugins_command.py | 4 +- .../test_pool_command.py | 2 +- .../test_rotate_fernet_key_command.py | 2 +- .../test_scheduler_command.py | 36 ++-- .../test_standalone_command.py | 2 +- .../test_task_command.py | 8 +- .../test_triggerer_command.py | 12 +- .../test_variable_command.py | 2 +- .../test_version_command.py | 4 +- .../unit/listeners/file_write_listener.py | 2 +- .../providers/celery/cli/celery_command.py | 6 +- .../unit/celery/cli/test_celery_command.py | 8 +- .../auth_manager/cli_commands/db_command.py | 2 +- .../run_provider_yaml_files_check.py | 2 +- 59 files changed, 221 insertions(+), 299 deletions(-) rename airflow-core/src/airflow/cli/commands/{local_commands => }/api_server_command.py (100%) rename airflow-core/src/airflow/cli/commands/{remote_commands => }/asset_command.py (100%) rename airflow-core/src/airflow/cli/commands/{remote_commands => }/backfill_command.py (100%) rename airflow-core/src/airflow/cli/commands/{local_commands => }/cheat_sheet_command.py (100%) rename airflow-core/src/airflow/cli/commands/{remote_commands => }/config_command.py (100%) rename airflow-core/src/airflow/cli/commands/{remote_commands => }/connection_command.py (100%) rename airflow-core/src/airflow/cli/commands/{local_commands => }/daemon_utils.py (100%) rename airflow-core/src/airflow/cli/commands/{remote_commands => }/dag_command.py (100%) rename airflow-core/src/airflow/cli/commands/{local_commands => }/dag_processor_command.py (95%) rename airflow-core/src/airflow/cli/commands/{local_commands => }/db_command.py (100%) rename airflow-core/src/airflow/cli/commands/{local_commands => }/info_command.py (100%) rename airflow-core/src/airflow/cli/commands/{remote_commands => }/jobs_command.py (100%) rename airflow-core/src/airflow/cli/commands/{local_commands => }/kerberos_command.py (94%) delete mode 100644 airflow-core/src/airflow/cli/commands/local_commands/__init__.py rename airflow-core/src/airflow/cli/commands/{local_commands => }/plugins_command.py (100%) rename airflow-core/src/airflow/cli/commands/{remote_commands => }/pool_command.py (100%) rename airflow-core/src/airflow/cli/commands/{remote_commands => }/provider_command.py (100%) delete mode 100644 airflow-core/src/airflow/cli/commands/remote_commands/__init__.py rename airflow-core/src/airflow/cli/commands/{local_commands => }/rotate_fernet_key_command.py (100%) rename airflow-core/src/airflow/cli/commands/{local_commands => }/scheduler_command.py (96%) rename airflow-core/src/airflow/cli/commands/{local_commands => }/standalone_command.py (100%) rename airflow-core/src/airflow/cli/commands/{remote_commands => }/task_command.py (100%) rename airflow-core/src/airflow/cli/commands/{local_commands => }/triggerer_command.py (96%) rename airflow-core/src/airflow/cli/commands/{remote_commands => }/variable_command.py (100%) rename airflow-core/src/airflow/cli/commands/{remote_commands => }/version_command.py (100%) delete mode 100644 airflow-core/tests/unit/cli/commands/local_commands/__init__.py delete mode 100644 airflow-core/tests/unit/cli/commands/remote_commands/__init__.py rename airflow-core/tests/unit/cli/commands/{local_commands => }/test_api_server_command.py (98%) rename airflow-core/tests/unit/cli/commands/{remote_commands => }/test_asset_command.py (98%) rename airflow-core/tests/unit/cli/commands/{remote_commands => }/test_backfill_command.py (89%) rename airflow-core/tests/unit/cli/commands/{local_commands => }/test_cheat_sheet_command.py (100%) rename airflow-core/tests/unit/cli/commands/{remote_commands => }/test_config_command.py (97%) rename airflow-core/tests/unit/cli/commands/{remote_commands => }/test_connection_command.py (99%) rename airflow-core/tests/unit/cli/commands/{remote_commands => }/test_dag_command.py (96%) rename airflow-core/tests/unit/cli/commands/{local_commands => }/test_dag_processor_command.py (88%) rename airflow-core/tests/unit/cli/commands/{local_commands => }/test_db_command.py (88%) rename airflow-core/tests/unit/cli/commands/{local_commands => }/test_info_command.py (97%) rename airflow-core/tests/unit/cli/commands/{remote_commands => }/test_jobs_command.py (99%) rename airflow-core/tests/unit/cli/commands/{local_commands => }/test_kerberos_command.py (87%) rename airflow-core/tests/unit/cli/commands/{local_commands => }/test_plugins_command.py (97%) rename airflow-core/tests/unit/cli/commands/{remote_commands => }/test_pool_command.py (99%) rename airflow-core/tests/unit/cli/commands/{local_commands => }/test_rotate_fernet_key_command.py (98%) rename airflow-core/tests/unit/cli/commands/{local_commands => }/test_scheduler_command.py (81%) rename airflow-core/tests/unit/cli/commands/{local_commands => }/test_standalone_command.py (96%) rename airflow-core/tests/unit/cli/commands/{remote_commands => }/test_task_command.py (98%) rename airflow-core/tests/unit/cli/commands/{local_commands => }/test_triggerer_command.py (81%) rename airflow-core/tests/unit/cli/commands/{remote_commands => }/test_variable_command.py (99%) rename airflow-core/tests/unit/cli/commands/{remote_commands => }/test_version_command.py (87%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 875abb3798e41..433517a690965 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -52,7 +52,7 @@ /docs/apache-airflow/concepts/dynamic-task-mapping.rst @uranusjr # Async Operators & Triggerer -/airflow-core/src/airflow/cli/commands/local_commands/triggerer_command.py @dstandish @hussein-awala +/airflow-core/src/airflow/cli/commands/triggerer_command.py @dstandish @hussein-awala /airflow-core/src/airflow/jobs/triggerer_job.py @dstandish @hussein-awala /airflow-core/src/airflow/jobs/triggerer_job_runner.py @dstandish @hussein-awala /docs/apache-airflow/authoring-and-scheduling/deferring.rst @dstandish @hussein-awala diff --git a/.github/boring-cyborg.yml b/.github/boring-cyborg.yml index b7da63728ae54..7120ac1a54d92 100644 --- a/.github/boring-cyborg.yml +++ b/.github/boring-cyborg.yml @@ -352,9 +352,9 @@ labelPRBasedOnFilePath: - providers/**/log/* area:Plugins: - - airflow-core/src/airflow/cli/commands/local_commands/plugins_command.py + - airflow-core/src/airflow/cli/commands/plugins_command.py - airflow-core/src/airflow/plugins_manager.py - - airflow-core/tests/unit/cli/commands/local_commands/test_plugins_command.py + - airflow-core/tests/unit/cli/commands/test_plugins_command.py - airflow-core/tests/unit/plugins/**/* - airflow-core/docs/administration-and-deployment/plugins.rst @@ -381,11 +381,11 @@ labelPRBasedOnFilePath: - airflow-core/docs/security/secrets/**/* area:Triggerer: - - airflow-core/src/airflow/cli/commands/local_commands/triggerer_command.py + - airflow-core/src/airflow/cli/commands/triggerer_command.py - airflow-core/src/airflow/jobs/triggerer_job_runner.py - airflow-core/src/airflow/models/trigger.py - providers/standard/src/airflow/providers/standard/triggers/**/* - - airflow-core/tests/unit/cli/commands/local_commands/test_triggerer_command.py + - airflow-core/tests/unit/cli/commands/test_triggerer_command.py - airflow-core/tests/unit/jobs/test_triggerer_job.py - airflow-core/tests/unit/models/test_trigger.py - providers/standard/tests/unit/standard/triggers/**/* diff --git a/airflow-core/src/airflow/api_fastapi/gunicorn_config.py b/airflow-core/src/airflow/api_fastapi/gunicorn_config.py index d9e8a9f7351d1..f2c17eef76d4f 100644 --- a/airflow-core/src/airflow/api_fastapi/gunicorn_config.py +++ b/airflow-core/src/airflow/api_fastapi/gunicorn_config.py @@ -27,7 +27,7 @@ def post_worker_init(_): """ Set process title. - This is used by airflow.cli.commands.local_commands.api_server_command to track the status of the worker. + This is used by airflow.cli.commands.api_server_command to track the status of the worker. """ old_title = setproctitle.getproctitle() setproctitle.setproctitle(settings.GUNICORN_WORKER_READY_PREFIX + old_title) diff --git a/airflow-core/src/airflow/cli/cli_config.py b/airflow-core/src/airflow/cli/cli_config.py index 717bd8b3b3e5d..ee34d083ab583 100644 --- a/airflow-core/src/airflow/cli/cli_config.py +++ b/airflow-core/src/airflow/cli/cli_config.py @@ -434,7 +434,7 @@ def string_lower_type(val): ("-t", "--tables"), help=lazy_object_proxy.Proxy( lambda: f"Table names to perform maintenance on (use comma-separated list).\n" - f"Options: {import_string('airflow.cli.commands.local_commands.db_command.all_tables')}" + f"Options: {import_string('airflow.cli.commands.db_command.all_tables')}" ), type=string_list_type, ) @@ -891,13 +891,13 @@ class GroupCommand(NamedTuple): ActionCommand( name="list", help="List assets", - func=lazy_load_command("airflow.cli.commands.remote_commands.asset_command.asset_list"), + func=lazy_load_command("airflow.cli.commands.asset_command.asset_list"), args=(ARG_ASSET_ALIAS, ARG_OUTPUT, ARG_VERBOSE, ARG_ASSET_LIST_COLUMNS), ), ActionCommand( name="details", help="Show asset details", - func=lazy_load_command("airflow.cli.commands.remote_commands.asset_command.asset_details"), + func=lazy_load_command("airflow.cli.commands.asset_command.asset_details"), args=(ARG_ASSET_ALIAS, ARG_ASSET_NAME, ARG_ASSET_URI, ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( @@ -912,7 +912,7 @@ class GroupCommand(NamedTuple): name="create", help="Create a backfill for a dag.", description="Run subsections of a DAG for a specified date range.", - func=lazy_load_command("airflow.cli.commands.remote_commands.backfill_command.create_backfill"), + func=lazy_load_command("airflow.cli.commands.backfill_command.create_backfill"), args=( ARG_BACKFILL_DAG, ARG_BACKFILL_FROM_DATE, @@ -929,25 +929,25 @@ class GroupCommand(NamedTuple): ActionCommand( name="details", help="Get DAG details given a DAG id", - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_details"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_details"), args=(ARG_DAG_ID, ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="list", help="List all the DAGs", - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_list_dags"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_list_dags"), args=(ARG_OUTPUT, ARG_VERBOSE, ARG_DAG_LIST_COLUMNS, ARG_BUNDLE_NAME), ), ActionCommand( name="list-import-errors", help="List all the DAGs that have import errors", - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_list_import_errors"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_list_import_errors"), args=(ARG_BUNDLE_NAME, ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="report", help="Show DagBag loading report", - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_report"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_report"), args=(ARG_BUNDLE_NAME, ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( @@ -960,7 +960,7 @@ class GroupCommand(NamedTuple): "dagruns that were executed before this date. If end_date is given, it will filter out " "all the dagruns that were executed after this date. " ), - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_list_dag_runs"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_list_dag_runs"), args=( ARG_DAG_ID, ARG_NO_BACKFILL, @@ -974,13 +974,13 @@ class GroupCommand(NamedTuple): ActionCommand( name="list-jobs", help="List the jobs", - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_list_jobs"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_list_jobs"), args=(ARG_DAG_ID_OPT, ARG_JOB_STATE, ARG_LIMIT, ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="state", help="Get the status of a dag run", - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_state"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_state"), args=(ARG_DAG_ID, ARG_LOGICAL_DATE_OR_RUN_ID, ARG_VERBOSE), ), ActionCommand( @@ -990,7 +990,7 @@ class GroupCommand(NamedTuple): "Get the next logical datetimes of a DAG. It returns one execution unless the " "num-executions option is given" ), - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_next_execution"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_next_execution"), args=(ARG_DAG_ID, ARG_NUM_EXECUTIONS, ARG_VERBOSE), ), ActionCommand( @@ -1001,7 +1001,7 @@ class GroupCommand(NamedTuple): "disabling further task scheduling. Use `--treat-dag-id-as-regex` to target multiple DAGs by " "treating the `--dag-id` as a regex pattern." ), - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_pause"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_pause"), args=(ARG_DAG_ID, ARG_TREAT_DAG_ID_AS_REGEX, ARG_YES, ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( @@ -1012,7 +1012,7 @@ class GroupCommand(NamedTuple): "DAGs, enabling further task scheduling. Use `--treat-dag-id-as-regex` to target multiple DAGs " "treating the `--dag-id` as a regex pattern." ), - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_unpause"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_unpause"), args=(ARG_DAG_ID, ARG_TREAT_DAG_ID_AS_REGEX, ARG_YES, ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( @@ -1021,7 +1021,7 @@ class GroupCommand(NamedTuple): "Trigger a new DAG run. If DAG is paused then dagrun state will remain queued, " "and the task won't run." ), - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_trigger"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_trigger"), args=( ARG_DAG_ID, ARG_RUN_ID, @@ -1035,7 +1035,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="delete", help="Delete all DB records related to the specified DAG", - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_delete"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_delete"), args=(ARG_DAG_ID, ARG_YES, ARG_VERBOSE), ), ActionCommand( @@ -1058,7 +1058,7 @@ class GroupCommand(NamedTuple): "If you want to create a DOT file then you should execute the following command:\n" "airflow dags show --save output.dot\n" ), - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_show"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_show"), args=(ARG_DAG_ID, ARG_SAVE, ARG_IMGCAT, ARG_VERBOSE), ), ActionCommand( @@ -1081,7 +1081,7 @@ class GroupCommand(NamedTuple): "If you want to create a DOT file then you should execute the following command:\n" "airflow dags show-dependencies --save output.dot\n" ), - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_dependencies_show"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_dependencies_show"), args=( ARG_SAVE, ARG_IMGCAT, @@ -1110,7 +1110,7 @@ class GroupCommand(NamedTuple): "If you want to create a DOT file then you should execute the following command:\n" "airflow dags test --save-dagrun output.dot\n" ), - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_test"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_test"), args=( ARG_DAG_ID, ARG_LOGICAL_DATE_OPTIONAL, @@ -1131,7 +1131,7 @@ class GroupCommand(NamedTuple): "particularly useful if your serialized DAGs become out of sync with the Airflow " "version you are using." ), - func=lazy_load_command("airflow.cli.commands.remote_commands.dag_command.dag_reserialize"), + func=lazy_load_command("airflow.cli.commands.dag_command.dag_reserialize"), args=( ARG_BUNDLE_NAME, ARG_VERBOSE, @@ -1142,13 +1142,13 @@ class GroupCommand(NamedTuple): ActionCommand( name="list", help="List the tasks within a DAG", - func=lazy_load_command("airflow.cli.commands.remote_commands.task_command.task_list"), + func=lazy_load_command("airflow.cli.commands.task_command.task_list"), args=(ARG_DAG_ID, ARG_SUBDIR, ARG_VERBOSE), ), ActionCommand( name="clear", help="Clear a set of task instance, as if they never ran", - func=lazy_load_command("airflow.cli.commands.remote_commands.task_command.task_clear"), + func=lazy_load_command("airflow.cli.commands.task_command.task_clear"), args=( ARG_DAG_ID, ARG_TASK_REGEX, @@ -1167,7 +1167,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="state", help="Get the status of a task instance", - func=lazy_load_command("airflow.cli.commands.remote_commands.task_command.task_state"), + func=lazy_load_command("airflow.cli.commands.task_command.task_state"), args=( ARG_DAG_ID, ARG_TASK_ID, @@ -1185,13 +1185,13 @@ class GroupCommand(NamedTuple): "In other words, why a task instance doesn't get scheduled and then queued by the scheduler, " "and then run by an executor." ), - func=lazy_load_command("airflow.cli.commands.remote_commands.task_command.task_failed_deps"), + func=lazy_load_command("airflow.cli.commands.task_command.task_failed_deps"), args=(ARG_DAG_ID, ARG_TASK_ID, ARG_LOGICAL_DATE_OR_RUN_ID, ARG_SUBDIR, ARG_MAP_INDEX, ARG_VERBOSE), ), ActionCommand( name="render", help="Render a task instance's template(s)", - func=lazy_load_command("airflow.cli.commands.remote_commands.task_command.task_render"), + func=lazy_load_command("airflow.cli.commands.task_command.task_render"), args=( ARG_DAG_ID, ARG_TASK_ID, @@ -1208,7 +1208,7 @@ class GroupCommand(NamedTuple): "Test a task instance. This will run a task without checking for dependencies or recording " "its state in the database" ), - func=lazy_load_command("airflow.cli.commands.remote_commands.task_command.task_test"), + func=lazy_load_command("airflow.cli.commands.task_command.task_test"), args=( ARG_DAG_ID, ARG_TASK_ID, @@ -1225,7 +1225,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="states-for-dag-run", help="Get the status of all task instances in a dag run", - func=lazy_load_command("airflow.cli.commands.remote_commands.task_command.task_states_for_dag_run"), + func=lazy_load_command("airflow.cli.commands.task_command.task_states_for_dag_run"), args=(ARG_DAG_ID, ARG_LOGICAL_DATE_OR_RUN_ID, ARG_OUTPUT, ARG_VERBOSE), ), ) @@ -1233,19 +1233,19 @@ class GroupCommand(NamedTuple): ActionCommand( name="list", help="List pools", - func=lazy_load_command("airflow.cli.commands.remote_commands.pool_command.pool_list"), + func=lazy_load_command("airflow.cli.commands.pool_command.pool_list"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="get", help="Get pool size", - func=lazy_load_command("airflow.cli.commands.remote_commands.pool_command.pool_get"), + func=lazy_load_command("airflow.cli.commands.pool_command.pool_get"), args=(ARG_POOL_NAME, ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="set", help="Configure pool", - func=lazy_load_command("airflow.cli.commands.remote_commands.pool_command.pool_set"), + func=lazy_load_command("airflow.cli.commands.pool_command.pool_set"), args=( ARG_POOL_NAME, ARG_POOL_SLOTS, @@ -1258,19 +1258,19 @@ class GroupCommand(NamedTuple): ActionCommand( name="delete", help="Delete pool", - func=lazy_load_command("airflow.cli.commands.remote_commands.pool_command.pool_delete"), + func=lazy_load_command("airflow.cli.commands.pool_command.pool_delete"), args=(ARG_POOL_NAME, ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="import", help="Import pools", - func=lazy_load_command("airflow.cli.commands.remote_commands.pool_command.pool_import"), + func=lazy_load_command("airflow.cli.commands.pool_command.pool_import"), args=(ARG_POOL_IMPORT, ARG_VERBOSE), ), ActionCommand( name="export", help="Export all pools", - func=lazy_load_command("airflow.cli.commands.remote_commands.pool_command.pool_export"), + func=lazy_load_command("airflow.cli.commands.pool_command.pool_export"), args=(ARG_POOL_EXPORT, ARG_VERBOSE), ), ) @@ -1278,31 +1278,31 @@ class GroupCommand(NamedTuple): ActionCommand( name="list", help="List variables", - func=lazy_load_command("airflow.cli.commands.remote_commands.variable_command.variables_list"), + func=lazy_load_command("airflow.cli.commands.variable_command.variables_list"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="get", help="Get variable", - func=lazy_load_command("airflow.cli.commands.remote_commands.variable_command.variables_get"), + func=lazy_load_command("airflow.cli.commands.variable_command.variables_get"), args=(ARG_VAR, ARG_DESERIALIZE_JSON, ARG_DEFAULT, ARG_VERBOSE), ), ActionCommand( name="set", help="Set variable", - func=lazy_load_command("airflow.cli.commands.remote_commands.variable_command.variables_set"), + func=lazy_load_command("airflow.cli.commands.variable_command.variables_set"), args=(ARG_VAR, ARG_VAR_VALUE, ARG_VAR_DESCRIPTION, ARG_SERIALIZE_JSON, ARG_VERBOSE), ), ActionCommand( name="delete", help="Delete variable", - func=lazy_load_command("airflow.cli.commands.remote_commands.variable_command.variables_delete"), + func=lazy_load_command("airflow.cli.commands.variable_command.variables_delete"), args=(ARG_VAR, ARG_VERBOSE), ), ActionCommand( name="import", help="Import variables", - func=lazy_load_command("airflow.cli.commands.remote_commands.variable_command.variables_import"), + func=lazy_load_command("airflow.cli.commands.variable_command.variables_import"), args=(ARG_VAR_IMPORT, ARG_VAR_ACTION_ON_EXISTING_KEY, ARG_VERBOSE), ), ActionCommand( @@ -1312,7 +1312,7 @@ class GroupCommand(NamedTuple): "All variables can be exported in STDOUT using the following command:\n" "airflow variables export -\n" ), - func=lazy_load_command("airflow.cli.commands.remote_commands.variable_command.variables_export"), + func=lazy_load_command("airflow.cli.commands.variable_command.variables_export"), args=(ARG_VAR_EXPORT, ARG_VERBOSE), ), ) @@ -1321,13 +1321,13 @@ class GroupCommand(NamedTuple): name="check-migrations", help="Check if migration have finished", description="Check if migration have finished (or continually check until timeout)", - func=lazy_load_command("airflow.cli.commands.local_commands.db_command.check_migrations"), + func=lazy_load_command("airflow.cli.commands.db_command.check_migrations"), args=(ARG_MIGRATION_TIMEOUT, ARG_VERBOSE), ), ActionCommand( name="reset", help="Burn down and rebuild the metadata database", - func=lazy_load_command("airflow.cli.commands.local_commands.db_command.resetdb"), + func=lazy_load_command("airflow.cli.commands.db_command.resetdb"), args=(ARG_YES, ARG_DB_SKIP_INIT, ARG_VERBOSE), ), ActionCommand( @@ -1341,7 +1341,7 @@ class GroupCommand(NamedTuple): "``--show-sql-only``, because if actually *running* migrations, we should only " "migrate from the *current* Alembic revision." ), - func=lazy_load_command("airflow.cli.commands.local_commands.db_command.migratedb"), + func=lazy_load_command("airflow.cli.commands.db_command.migratedb"), args=( ARG_DB_REVISION__UPGRADE, ARG_DB_VERSION__UPGRADE, @@ -1362,7 +1362,7 @@ class GroupCommand(NamedTuple): "because if actually *running* migrations, we should only migrate from the *current* Alembic " "revision." ), - func=lazy_load_command("airflow.cli.commands.local_commands.db_command.downgrade"), + func=lazy_load_command("airflow.cli.commands.db_command.downgrade"), args=( ARG_DB_REVISION__DOWNGRADE, ARG_DB_VERSION__DOWNGRADE, @@ -1376,19 +1376,19 @@ class GroupCommand(NamedTuple): ActionCommand( name="shell", help="Runs a shell to access the database", - func=lazy_load_command("airflow.cli.commands.local_commands.db_command.shell"), + func=lazy_load_command("airflow.cli.commands.db_command.shell"), args=(ARG_VERBOSE,), ), ActionCommand( name="check", help="Check if the database can be reached", - func=lazy_load_command("airflow.cli.commands.local_commands.db_command.check"), + func=lazy_load_command("airflow.cli.commands.db_command.check"), args=(ARG_VERBOSE, ARG_DB_RETRY, ARG_DB_RETRY_DELAY), ), ActionCommand( name="clean", help="Purge old records in metastore tables", - func=lazy_load_command("airflow.cli.commands.local_commands.db_command.cleanup_tables"), + func=lazy_load_command("airflow.cli.commands.db_command.cleanup_tables"), args=( ARG_DB_TABLES, ARG_DB_DRY_RUN, @@ -1401,7 +1401,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="export-archived", help="Export archived data from the archive tables", - func=lazy_load_command("airflow.cli.commands.local_commands.db_command.export_archived"), + func=lazy_load_command("airflow.cli.commands.db_command.export_archived"), args=( ARG_DB_EXPORT_FORMAT, ARG_DB_OUTPUT_PATH, @@ -1413,7 +1413,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="drop-archived", help="Drop archived tables created through the db clean command", - func=lazy_load_command("airflow.cli.commands.local_commands.db_command.drop_archived"), + func=lazy_load_command("airflow.cli.commands.db_command.drop_archived"), args=(ARG_DB_TABLES, ARG_YES), ), ) @@ -1421,25 +1421,25 @@ class GroupCommand(NamedTuple): ActionCommand( name="get", help="Get a connection", - func=lazy_load_command("airflow.cli.commands.remote_commands.connection_command.connections_get"), + func=lazy_load_command("airflow.cli.commands.connection_command.connections_get"), args=(ARG_CONN_ID, ARG_COLOR, ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="list", help="List connections", - func=lazy_load_command("airflow.cli.commands.remote_commands.connection_command.connections_list"), + func=lazy_load_command("airflow.cli.commands.connection_command.connections_list"), args=(ARG_OUTPUT, ARG_VERBOSE, ARG_CONN_ID_FILTER), ), ActionCommand( name="add", help="Add a connection", - func=lazy_load_command("airflow.cli.commands.remote_commands.connection_command.connections_add"), + func=lazy_load_command("airflow.cli.commands.connection_command.connections_add"), args=(ARG_CONN_ID, ARG_CONN_URI, ARG_CONN_JSON, ARG_CONN_EXTRA, *ALTERNATIVE_CONN_SPECS_ARGS), ), ActionCommand( name="delete", help="Delete a connection", - func=lazy_load_command("airflow.cli.commands.remote_commands.connection_command.connections_delete"), + func=lazy_load_command("airflow.cli.commands.connection_command.connections_delete"), args=(ARG_CONN_ID, ARG_COLOR, ARG_VERBOSE), ), ActionCommand( @@ -1460,7 +1460,7 @@ class GroupCommand(NamedTuple): "is used to serialize the connection by passing `uri` or `json` with option " "`--serialization-format`.\n" ), - func=lazy_load_command("airflow.cli.commands.remote_commands.connection_command.connections_export"), + func=lazy_load_command("airflow.cli.commands.connection_command.connections_export"), args=( ARG_CONN_EXPORT, ARG_CONN_EXPORT_FORMAT, @@ -1476,7 +1476,7 @@ class GroupCommand(NamedTuple): "Connections can be imported from the output of the export command.\n" "The filetype must by json, yaml or env and will be automatically inferred." ), - func=lazy_load_command("airflow.cli.commands.remote_commands.connection_command.connections_import"), + func=lazy_load_command("airflow.cli.commands.connection_command.connections_import"), args=( ARG_CONN_IMPORT, ARG_CONN_OVERWRITE, @@ -1486,15 +1486,13 @@ class GroupCommand(NamedTuple): ActionCommand( name="test", help="Test a connection", - func=lazy_load_command("airflow.cli.commands.remote_commands.connection_command.connections_test"), + func=lazy_load_command("airflow.cli.commands.connection_command.connections_test"), args=(ARG_CONN_ID, ARG_VERBOSE), ), ActionCommand( name="create-default-connections", help="Creates all the default connections from all the providers", - func=lazy_load_command( - "airflow.cli.commands.remote_commands.connection_command.create_default_connections" - ), + func=lazy_load_command("airflow.cli.commands.connection_command.create_default_connections"), args=(ARG_VERBOSE,), ), ) @@ -1502,27 +1500,25 @@ class GroupCommand(NamedTuple): ActionCommand( name="list", help="List installed providers", - func=lazy_load_command("airflow.cli.commands.remote_commands.provider_command.providers_list"), + func=lazy_load_command("airflow.cli.commands.provider_command.providers_list"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="get", help="Get detailed information about a provider", - func=lazy_load_command("airflow.cli.commands.remote_commands.provider_command.provider_get"), + func=lazy_load_command("airflow.cli.commands.provider_command.provider_get"), args=(ARG_OUTPUT, ARG_VERBOSE, ARG_FULL, ARG_COLOR, ARG_PROVIDER_NAME), ), ActionCommand( name="links", help="List extra links registered by the providers", - func=lazy_load_command("airflow.cli.commands.remote_commands.provider_command.extra_links_list"), + func=lazy_load_command("airflow.cli.commands.provider_command.extra_links_list"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="widgets", help="Get information about registered connection form widgets", - func=lazy_load_command( - "airflow.cli.commands.remote_commands.provider_command.connection_form_widget_list" - ), + func=lazy_load_command("airflow.cli.commands.provider_command.connection_form_widget_list"), args=( ARG_OUTPUT, ARG_VERBOSE, @@ -1531,63 +1527,61 @@ class GroupCommand(NamedTuple): ActionCommand( name="hooks", help="List registered provider hooks", - func=lazy_load_command("airflow.cli.commands.remote_commands.provider_command.hooks_list"), + func=lazy_load_command("airflow.cli.commands.provider_command.hooks_list"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="triggers", help="List registered provider triggers", - func=lazy_load_command("airflow.cli.commands.remote_commands.provider_command.triggers_list"), + func=lazy_load_command("airflow.cli.commands.provider_command.triggers_list"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="behaviours", help="Get information about registered connection types with custom behaviours", - func=lazy_load_command( - "airflow.cli.commands.remote_commands.provider_command.connection_field_behaviours" - ), + func=lazy_load_command("airflow.cli.commands.provider_command.connection_field_behaviours"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="logging", help="Get information about task logging handlers provided", - func=lazy_load_command("airflow.cli.commands.remote_commands.provider_command.logging_list"), + func=lazy_load_command("airflow.cli.commands.provider_command.logging_list"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="secrets", help="Get information about secrets backends provided", - func=lazy_load_command("airflow.cli.commands.remote_commands.provider_command.secrets_backends_list"), + func=lazy_load_command("airflow.cli.commands.provider_command.secrets_backends_list"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="executors", help="Get information about executors provided", - func=lazy_load_command("airflow.cli.commands.remote_commands.provider_command.executors_list"), + func=lazy_load_command("airflow.cli.commands.provider_command.executors_list"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="notifications", help="Get information about notifications provided", - func=lazy_load_command("airflow.cli.commands.remote_commands.provider_command.notifications_list"), + func=lazy_load_command("airflow.cli.commands.provider_command.notifications_list"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="configs", help="Get information about provider configuration", - func=lazy_load_command("airflow.cli.commands.remote_commands.provider_command.config_list"), + func=lazy_load_command("airflow.cli.commands.provider_command.config_list"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="lazy-loaded", help="Checks that provider configuration is lazy loaded", - func=lazy_load_command("airflow.cli.commands.remote_commands.provider_command.lazy_loaded"), + func=lazy_load_command("airflow.cli.commands.provider_command.lazy_loaded"), args=(ARG_VERBOSE,), ), ActionCommand( name="auth-managers", help="Get information about auth managers provided", - func=lazy_load_command("airflow.cli.commands.remote_commands.provider_command.auth_managers_list"), + func=lazy_load_command("airflow.cli.commands.provider_command.auth_managers_list"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ) @@ -1597,7 +1591,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="get-value", help="Print the value of the configuration", - func=lazy_load_command("airflow.cli.commands.remote_commands.config_command.get_value"), + func=lazy_load_command("airflow.cli.commands.config_command.get_value"), args=( ARG_SECTION, ARG_OPTION, @@ -1607,7 +1601,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="list", help="List options for the configuration", - func=lazy_load_command("airflow.cli.commands.remote_commands.config_command.show_config"), + func=lazy_load_command("airflow.cli.commands.config_command.show_config"), args=( ARG_OPTIONAL_SECTION, ARG_COLOR, @@ -1624,7 +1618,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="lint", help="lint options for the configuration changes while migrating from Airflow 2.x to Airflow 3.0", - func=lazy_load_command("airflow.cli.commands.remote_commands.config_command.lint_config"), + func=lazy_load_command("airflow.cli.commands.config_command.lint_config"), args=( ARG_LINT_CONFIG_SECTION, ARG_LINT_CONFIG_OPTION, @@ -1639,7 +1633,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="check", help="Checks if job(s) are still alive", - func=lazy_load_command("airflow.cli.commands.remote_commands.jobs_command.check"), + func=lazy_load_command("airflow.cli.commands.jobs_command.check"), args=( ARG_JOB_TYPE_FILTER, ARG_JOB_HOSTNAME_FILTER, @@ -1705,7 +1699,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="kerberos", help="Start a kerberos ticket renewer", - func=lazy_load_command("airflow.cli.commands.local_commands.kerberos_command.kerberos"), + func=lazy_load_command("airflow.cli.commands.kerberos_command.kerberos"), args=( ARG_PRINCIPAL, ARG_KEYTAB, @@ -1721,7 +1715,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="api-server", help="Start an Airflow API server instance", - func=lazy_load_command("airflow.cli.commands.local_commands.api_server_command.api_server"), + func=lazy_load_command("airflow.cli.commands.api_server_command.api_server"), args=( ARG_API_SERVER_PORT, ARG_API_SERVER_WORKERS, @@ -1743,7 +1737,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="scheduler", help="Start a scheduler instance", - func=lazy_load_command("airflow.cli.commands.local_commands.scheduler_command.scheduler"), + func=lazy_load_command("airflow.cli.commands.scheduler_command.scheduler"), args=( ARG_NUM_RUNS, ARG_PID, @@ -1766,7 +1760,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="triggerer", help="Start a triggerer instance", - func=lazy_load_command("airflow.cli.commands.local_commands.triggerer_command.triggerer"), + func=lazy_load_command("airflow.cli.commands.triggerer_command.triggerer"), args=( ARG_PID, ARG_DAEMON, @@ -1781,7 +1775,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="dag-processor", help="Start a dag processor instance", - func=lazy_load_command("airflow.cli.commands.local_commands.dag_processor_command.dag_processor"), + func=lazy_load_command("airflow.cli.commands.dag_processor_command.dag_processor"), args=( ARG_PID, ARG_DAEMON, @@ -1796,13 +1790,13 @@ class GroupCommand(NamedTuple): ActionCommand( name="version", help="Show the version", - func=lazy_load_command("airflow.cli.commands.remote_commands.version_command.version"), + func=lazy_load_command("airflow.cli.commands.version_command.version"), args=(), ), ActionCommand( name="cheat-sheet", help="Display cheat sheet", - func=lazy_load_command("airflow.cli.commands.local_commands.cheat_sheet_command.cheat_sheet"), + func=lazy_load_command("airflow.cli.commands.cheat_sheet_command.cheat_sheet"), args=(ARG_VERBOSE,), ), GroupCommand( @@ -1817,9 +1811,7 @@ class GroupCommand(NamedTuple): ), ActionCommand( name="rotate-fernet-key", - func=lazy_load_command( - "airflow.cli.commands.local_commands.rotate_fernet_key_command.rotate_fernet_key" - ), + func=lazy_load_command("airflow.cli.commands.rotate_fernet_key_command.rotate_fernet_key"), help="Rotate encrypted connection credentials and variables", description=( "Rotate all encrypted connection credentials and variables; see " @@ -1832,7 +1824,7 @@ class GroupCommand(NamedTuple): ActionCommand( name="info", help="Show information about current Airflow and environment", - func=lazy_load_command("airflow.cli.commands.local_commands.info_command.show_info"), + func=lazy_load_command("airflow.cli.commands.info_command.show_info"), args=( ARG_ANONYMIZE, ARG_FILE_IO, @@ -1843,13 +1835,13 @@ class GroupCommand(NamedTuple): ActionCommand( name="plugins", help="Dump information about loaded plugins", - func=lazy_load_command("airflow.cli.commands.local_commands.plugins_command.dump_plugins"), + func=lazy_load_command("airflow.cli.commands.plugins_command.dump_plugins"), args=(ARG_OUTPUT, ARG_VERBOSE), ), ActionCommand( name="standalone", help="Run an all-in-one copy of Airflow", - func=lazy_load_command("airflow.cli.commands.local_commands.standalone_command.standalone"), + func=lazy_load_command("airflow.cli.commands.standalone_command.standalone"), args=(), ), ] diff --git a/airflow-core/src/airflow/cli/commands/local_commands/api_server_command.py b/airflow-core/src/airflow/cli/commands/api_server_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/local_commands/api_server_command.py rename to airflow-core/src/airflow/cli/commands/api_server_command.py diff --git a/airflow-core/src/airflow/cli/commands/remote_commands/asset_command.py b/airflow-core/src/airflow/cli/commands/asset_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/remote_commands/asset_command.py rename to airflow-core/src/airflow/cli/commands/asset_command.py diff --git a/airflow-core/src/airflow/cli/commands/remote_commands/backfill_command.py b/airflow-core/src/airflow/cli/commands/backfill_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/remote_commands/backfill_command.py rename to airflow-core/src/airflow/cli/commands/backfill_command.py diff --git a/airflow-core/src/airflow/cli/commands/local_commands/cheat_sheet_command.py b/airflow-core/src/airflow/cli/commands/cheat_sheet_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/local_commands/cheat_sheet_command.py rename to airflow-core/src/airflow/cli/commands/cheat_sheet_command.py diff --git a/airflow-core/src/airflow/cli/commands/remote_commands/config_command.py b/airflow-core/src/airflow/cli/commands/config_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/remote_commands/config_command.py rename to airflow-core/src/airflow/cli/commands/config_command.py diff --git a/airflow-core/src/airflow/cli/commands/remote_commands/connection_command.py b/airflow-core/src/airflow/cli/commands/connection_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/remote_commands/connection_command.py rename to airflow-core/src/airflow/cli/commands/connection_command.py diff --git a/airflow-core/src/airflow/cli/commands/local_commands/daemon_utils.py b/airflow-core/src/airflow/cli/commands/daemon_utils.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/local_commands/daemon_utils.py rename to airflow-core/src/airflow/cli/commands/daemon_utils.py diff --git a/airflow-core/src/airflow/cli/commands/remote_commands/dag_command.py b/airflow-core/src/airflow/cli/commands/dag_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/remote_commands/dag_command.py rename to airflow-core/src/airflow/cli/commands/dag_command.py diff --git a/airflow-core/src/airflow/cli/commands/local_commands/dag_processor_command.py b/airflow-core/src/airflow/cli/commands/dag_processor_command.py similarity index 95% rename from airflow-core/src/airflow/cli/commands/local_commands/dag_processor_command.py rename to airflow-core/src/airflow/cli/commands/dag_processor_command.py index cfd7fa65b973e..c866763338ff1 100644 --- a/airflow-core/src/airflow/cli/commands/local_commands/dag_processor_command.py +++ b/airflow-core/src/airflow/cli/commands/dag_processor_command.py @@ -21,7 +21,7 @@ import logging from typing import Any -from airflow.cli.commands.local_commands.daemon_utils import run_command_with_daemon_option +from airflow.cli.commands.daemon_utils import run_command_with_daemon_option from airflow.dag_processing.manager import DagFileProcessorManager, reload_configuration_for_dag_processing from airflow.jobs.dag_processor_job_runner import DagProcessorJobRunner from airflow.jobs.job import Job, run_job diff --git a/airflow-core/src/airflow/cli/commands/local_commands/db_command.py b/airflow-core/src/airflow/cli/commands/db_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/local_commands/db_command.py rename to airflow-core/src/airflow/cli/commands/db_command.py diff --git a/airflow-core/src/airflow/cli/commands/local_commands/info_command.py b/airflow-core/src/airflow/cli/commands/info_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/local_commands/info_command.py rename to airflow-core/src/airflow/cli/commands/info_command.py diff --git a/airflow-core/src/airflow/cli/commands/remote_commands/jobs_command.py b/airflow-core/src/airflow/cli/commands/jobs_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/remote_commands/jobs_command.py rename to airflow-core/src/airflow/cli/commands/jobs_command.py diff --git a/airflow-core/src/airflow/cli/commands/local_commands/kerberos_command.py b/airflow-core/src/airflow/cli/commands/kerberos_command.py similarity index 94% rename from airflow-core/src/airflow/cli/commands/local_commands/kerberos_command.py rename to airflow-core/src/airflow/cli/commands/kerberos_command.py index 6e3ed83ae8307..827f2d6a9d062 100644 --- a/airflow-core/src/airflow/cli/commands/local_commands/kerberos_command.py +++ b/airflow-core/src/airflow/cli/commands/kerberos_command.py @@ -19,7 +19,7 @@ from __future__ import annotations from airflow import settings -from airflow.cli.commands.local_commands.daemon_utils import run_command_with_daemon_option +from airflow.cli.commands.daemon_utils import run_command_with_daemon_option from airflow.security import kerberos as krb from airflow.security.kerberos import KerberosMode from airflow.utils import cli as cli_utils diff --git a/airflow-core/src/airflow/cli/commands/local_commands/__init__.py b/airflow-core/src/airflow/cli/commands/local_commands/__init__.py deleted file mode 100644 index 13a83393a9124..0000000000000 --- a/airflow-core/src/airflow/cli/commands/local_commands/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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. diff --git a/airflow-core/src/airflow/cli/commands/local_commands/plugins_command.py b/airflow-core/src/airflow/cli/commands/plugins_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/local_commands/plugins_command.py rename to airflow-core/src/airflow/cli/commands/plugins_command.py diff --git a/airflow-core/src/airflow/cli/commands/remote_commands/pool_command.py b/airflow-core/src/airflow/cli/commands/pool_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/remote_commands/pool_command.py rename to airflow-core/src/airflow/cli/commands/pool_command.py diff --git a/airflow-core/src/airflow/cli/commands/remote_commands/provider_command.py b/airflow-core/src/airflow/cli/commands/provider_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/remote_commands/provider_command.py rename to airflow-core/src/airflow/cli/commands/provider_command.py diff --git a/airflow-core/src/airflow/cli/commands/remote_commands/__init__.py b/airflow-core/src/airflow/cli/commands/remote_commands/__init__.py deleted file mode 100644 index 13a83393a9124..0000000000000 --- a/airflow-core/src/airflow/cli/commands/remote_commands/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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. diff --git a/airflow-core/src/airflow/cli/commands/local_commands/rotate_fernet_key_command.py b/airflow-core/src/airflow/cli/commands/rotate_fernet_key_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/local_commands/rotate_fernet_key_command.py rename to airflow-core/src/airflow/cli/commands/rotate_fernet_key_command.py diff --git a/airflow-core/src/airflow/cli/commands/local_commands/scheduler_command.py b/airflow-core/src/airflow/cli/commands/scheduler_command.py similarity index 96% rename from airflow-core/src/airflow/cli/commands/local_commands/scheduler_command.py rename to airflow-core/src/airflow/cli/commands/scheduler_command.py index 35a9ca8703b52..88206c76ba1a7 100644 --- a/airflow-core/src/airflow/cli/commands/local_commands/scheduler_command.py +++ b/airflow-core/src/airflow/cli/commands/scheduler_command.py @@ -24,7 +24,7 @@ from multiprocessing import Process from airflow import settings -from airflow.cli.commands.local_commands.daemon_utils import run_command_with_daemon_option +from airflow.cli.commands.daemon_utils import run_command_with_daemon_option from airflow.configuration import conf from airflow.executors.executor_loader import ExecutorLoader from airflow.jobs.job import Job, run_job diff --git a/airflow-core/src/airflow/cli/commands/local_commands/standalone_command.py b/airflow-core/src/airflow/cli/commands/standalone_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/local_commands/standalone_command.py rename to airflow-core/src/airflow/cli/commands/standalone_command.py diff --git a/airflow-core/src/airflow/cli/commands/remote_commands/task_command.py b/airflow-core/src/airflow/cli/commands/task_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/remote_commands/task_command.py rename to airflow-core/src/airflow/cli/commands/task_command.py diff --git a/airflow-core/src/airflow/cli/commands/local_commands/triggerer_command.py b/airflow-core/src/airflow/cli/commands/triggerer_command.py similarity index 96% rename from airflow-core/src/airflow/cli/commands/local_commands/triggerer_command.py rename to airflow-core/src/airflow/cli/commands/triggerer_command.py index 48306743f8b86..7b935e160ca5e 100644 --- a/airflow-core/src/airflow/cli/commands/local_commands/triggerer_command.py +++ b/airflow-core/src/airflow/cli/commands/triggerer_command.py @@ -24,7 +24,7 @@ from multiprocessing import Process from airflow import settings -from airflow.cli.commands.local_commands.daemon_utils import run_command_with_daemon_option +from airflow.cli.commands.daemon_utils import run_command_with_daemon_option from airflow.configuration import conf from airflow.jobs.job import Job, run_job from airflow.jobs.triggerer_job_runner import TriggererJobRunner diff --git a/airflow-core/src/airflow/cli/commands/remote_commands/variable_command.py b/airflow-core/src/airflow/cli/commands/variable_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/remote_commands/variable_command.py rename to airflow-core/src/airflow/cli/commands/variable_command.py diff --git a/airflow-core/src/airflow/cli/commands/remote_commands/version_command.py b/airflow-core/src/airflow/cli/commands/version_command.py similarity index 100% rename from airflow-core/src/airflow/cli/commands/remote_commands/version_command.py rename to airflow-core/src/airflow/cli/commands/version_command.py diff --git a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_job.py b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_job.py index 7cff95f95391e..b3e86ec8f23b1 100644 --- a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_job.py +++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_job.py @@ -129,7 +129,7 @@ class TestGetJobs(TestJobEndpoint): @pytest.mark.parametrize( "testcase, query_params, expected_status_code, expected_total_entries", [ - # original testcases refactor from tests/cli/commands/remote_commands/test_jobs_command.py + # original testcases refactor from tests/cli/commands/test_jobs_command.py (TESTCASE_ONE_SCHEDULER, {}, 200, 1), (TESTCASE_ONE_SCHEDULER_WITH_HOSTNAME, {"hostname": "HOSTNAME"}, 200, 1), (TESTCASE_HA_SCHEDULERS, {"limit": 100}, 200, 3), diff --git a/airflow-core/tests/unit/cli/commands/local_commands/__init__.py b/airflow-core/tests/unit/cli/commands/local_commands/__init__.py deleted file mode 100644 index 13a83393a9124..0000000000000 --- a/airflow-core/tests/unit/cli/commands/local_commands/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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. diff --git a/airflow-core/tests/unit/cli/commands/remote_commands/__init__.py b/airflow-core/tests/unit/cli/commands/remote_commands/__init__.py deleted file mode 100644 index 13a83393a9124..0000000000000 --- a/airflow-core/tests/unit/cli/commands/remote_commands/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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. diff --git a/airflow-core/tests/unit/cli/commands/local_commands/test_api_server_command.py b/airflow-core/tests/unit/cli/commands/test_api_server_command.py similarity index 98% rename from airflow-core/tests/unit/cli/commands/local_commands/test_api_server_command.py rename to airflow-core/tests/unit/cli/commands/test_api_server_command.py index 4ea314bf82696..837ee0f61bd1e 100644 --- a/airflow-core/tests/unit/cli/commands/local_commands/test_api_server_command.py +++ b/airflow-core/tests/unit/cli/commands/test_api_server_command.py @@ -21,7 +21,7 @@ import pytest from rich.console import Console -from airflow.cli.commands.local_commands import api_server_command +from airflow.cli.commands import api_server_command from airflow.exceptions import AirflowConfigException from unit.cli.commands._common_cli_classes import _CommonCLIGunicornTestClass diff --git a/airflow-core/tests/unit/cli/commands/remote_commands/test_asset_command.py b/airflow-core/tests/unit/cli/commands/test_asset_command.py similarity index 98% rename from airflow-core/tests/unit/cli/commands/remote_commands/test_asset_command.py rename to airflow-core/tests/unit/cli/commands/test_asset_command.py index 32fb07124de6b..64ae74ed8ff69 100644 --- a/airflow-core/tests/unit/cli/commands/remote_commands/test_asset_command.py +++ b/airflow-core/tests/unit/cli/commands/test_asset_command.py @@ -27,7 +27,7 @@ import pytest from airflow.cli import cli_parser -from airflow.cli.commands.remote_commands import asset_command +from airflow.cli.commands import asset_command from tests_common.test_utils.db import clear_db_dags, clear_db_runs, parse_and_sync_to_db diff --git a/airflow-core/tests/unit/cli/commands/remote_commands/test_backfill_command.py b/airflow-core/tests/unit/cli/commands/test_backfill_command.py similarity index 89% rename from airflow-core/tests/unit/cli/commands/remote_commands/test_backfill_command.py rename to airflow-core/tests/unit/cli/commands/test_backfill_command.py index d74f44b06b56a..d14f447e7d13e 100644 --- a/airflow-core/tests/unit/cli/commands/remote_commands/test_backfill_command.py +++ b/airflow-core/tests/unit/cli/commands/test_backfill_command.py @@ -25,7 +25,7 @@ import pendulum import pytest -import airflow.cli.commands.remote_commands.backfill_command +import airflow.cli.commands.backfill_command from airflow.cli import cli_parser from airflow.models.backfill import ReprocessBehavior from airflow.utils import timezone @@ -62,7 +62,7 @@ def setup_method(self): clear_db_dags() clear_db_backfills() - @mock.patch("airflow.cli.commands.remote_commands.backfill_command._create_backfill") + @mock.patch("airflow.cli.commands.backfill_command._create_backfill") @pytest.mark.parametrize( "repro, expected_repro", [ @@ -90,7 +90,7 @@ def test_backfill(self, mock_create, repro, expected_repro): repro, ] ) - airflow.cli.commands.remote_commands.backfill_command.create_backfill(self.parser.parse_args(args)) + airflow.cli.commands.backfill_command.create_backfill(self.parser.parse_args(args)) mock_create.assert_called_once_with( dag_id="example_bash_operator", @@ -102,7 +102,7 @@ def test_backfill(self, mock_create, repro, expected_repro): reprocess_behavior=expected_repro, ) - @mock.patch("airflow.cli.commands.remote_commands.backfill_command._do_dry_run") + @mock.patch("airflow.cli.commands.backfill_command._do_dry_run") @pytest.mark.parametrize( "reverse", [False, True], @@ -123,7 +123,7 @@ def test_backfill_dry_run(self, mock_dry_run, reverse): ] if reverse: args.append("--run-backwards") - airflow.cli.commands.remote_commands.backfill_command.create_backfill(self.parser.parse_args(args)) + airflow.cli.commands.backfill_command.create_backfill(self.parser.parse_args(args)) mock_dry_run.assert_called_once_with( dag_id="example_bash_operator", diff --git a/airflow-core/tests/unit/cli/commands/local_commands/test_cheat_sheet_command.py b/airflow-core/tests/unit/cli/commands/test_cheat_sheet_command.py similarity index 100% rename from airflow-core/tests/unit/cli/commands/local_commands/test_cheat_sheet_command.py rename to airflow-core/tests/unit/cli/commands/test_cheat_sheet_command.py diff --git a/airflow-core/tests/unit/cli/commands/remote_commands/test_config_command.py b/airflow-core/tests/unit/cli/commands/test_config_command.py similarity index 97% rename from airflow-core/tests/unit/cli/commands/remote_commands/test_config_command.py rename to airflow-core/tests/unit/cli/commands/test_config_command.py index aa0137f89e165..75dd395964edc 100644 --- a/airflow-core/tests/unit/cli/commands/remote_commands/test_config_command.py +++ b/airflow-core/tests/unit/cli/commands/test_config_command.py @@ -25,8 +25,8 @@ import pytest from airflow.cli import cli_parser -from airflow.cli.commands.remote_commands import config_command -from airflow.cli.commands.remote_commands.config_command import ConfigChange, ConfigParameter +from airflow.cli.commands import config_command +from airflow.cli.commands.config_command import ConfigChange, ConfigParameter from tests_common.test_utils.config import conf_vars @@ -38,8 +38,8 @@ class TestCliConfigList: def setup_class(cls): cls.parser = cli_parser.get_parser() - @mock.patch("airflow.cli.commands.remote_commands.config_command.StringIO") - @mock.patch("airflow.cli.commands.remote_commands.config_command.conf") + @mock.patch("airflow.cli.commands.config_command.StringIO") + @mock.patch("airflow.cli.commands.config_command.conf") def test_cli_show_config_should_write_data(self, mock_conf, mock_stringio): config_command.show_config(self.parser.parse_args(["config", "list", "--color", "off"])) mock_conf.write.assert_called_once_with( @@ -54,8 +54,8 @@ def test_cli_show_config_should_write_data(self, mock_conf, mock_stringio): only_defaults=False, ) - @mock.patch("airflow.cli.commands.remote_commands.config_command.StringIO") - @mock.patch("airflow.cli.commands.remote_commands.config_command.conf") + @mock.patch("airflow.cli.commands.config_command.StringIO") + @mock.patch("airflow.cli.commands.config_command.conf") def test_cli_show_config_should_write_data_specific_section(self, mock_conf, mock_stringio): config_command.show_config( self.parser.parse_args(["config", "list", "--section", "core", "--color", "off"]) @@ -222,7 +222,7 @@ def test_should_display_value(self): assert temp_stdout.getvalue().strip() == "test_value" - @mock.patch("airflow.cli.commands.remote_commands.config_command.conf") + @mock.patch("airflow.cli.commands.config_command.conf") def test_should_not_raise_exception_when_section_for_config_with_value_defined_elsewhere_is_missing( self, mock_conf ): diff --git a/airflow-core/tests/unit/cli/commands/remote_commands/test_connection_command.py b/airflow-core/tests/unit/cli/commands/test_connection_command.py similarity index 99% rename from airflow-core/tests/unit/cli/commands/remote_commands/test_connection_command.py rename to airflow-core/tests/unit/cli/commands/test_connection_command.py index ccfe38880b3f4..2222362f2bb36 100644 --- a/airflow-core/tests/unit/cli/commands/remote_commands/test_connection_command.py +++ b/airflow-core/tests/unit/cli/commands/test_connection_command.py @@ -28,7 +28,7 @@ import pytest from airflow.cli import cli_config, cli_parser -from airflow.cli.commands.remote_commands import connection_command +from airflow.cli.commands import connection_command from airflow.exceptions import AirflowException from airflow.models import Connection from airflow.utils.db import merge_conn @@ -986,7 +986,7 @@ def test_cli_connections_test_disabled_by_default(self): class TestCliCreateDefaultConnection: - @mock.patch("airflow.cli.commands.remote_commands.connection_command.db_create_default_connections") + @mock.patch("airflow.cli.commands.connection_command.db_create_default_connections") def test_cli_create_default_connections(self, mock_db_create_default_connections): create_default_connection_fnc = dict( (db_command.name, db_command.func) for db_command in cli_config.CONNECTIONS_COMMANDS diff --git a/airflow-core/tests/unit/cli/commands/remote_commands/test_dag_command.py b/airflow-core/tests/unit/cli/commands/test_dag_command.py similarity index 96% rename from airflow-core/tests/unit/cli/commands/remote_commands/test_dag_command.py rename to airflow-core/tests/unit/cli/commands/test_dag_command.py index 9b6c231e62fd7..33d33fac5bdae 100644 --- a/airflow-core/tests/unit/cli/commands/remote_commands/test_dag_command.py +++ b/airflow-core/tests/unit/cli/commands/test_dag_command.py @@ -34,7 +34,7 @@ from airflow import settings from airflow.cli import cli_parser -from airflow.cli.commands.remote_commands import dag_command +from airflow.cli.commands import dag_command from airflow.decorators import task from airflow.exceptions import AirflowException from airflow.models import DagBag, DagModel, DagRun @@ -95,7 +95,7 @@ def test_show_dag_dependencies_print(self): assert "digraph" in out assert "graph [rankdir=LR]" in out - @mock.patch("airflow.cli.commands.remote_commands.dag_command.render_dag_dependencies") + @mock.patch("airflow.cli.commands.dag_command.render_dag_dependencies") def test_show_dag_dependencies_save(self, mock_render_dag_dependencies): with contextlib.redirect_stdout(StringIO()) as temp_stdout: dag_command.dag_dependencies_show( @@ -115,7 +115,7 @@ def test_show_dag_print(self): assert "graph [label=example_bash_operator labelloc=t rankdir=LR]" in out assert "runme_2 -> run_after_loop" in out - @mock.patch("airflow.cli.commands.remote_commands.dag_command.render_dag") + @mock.patch("airflow.cli.commands.dag_command.render_dag") def test_show_dag_save(self, mock_render_dag): with contextlib.redirect_stdout(StringIO()) as temp_stdout: dag_command.dag_show( @@ -127,8 +127,8 @@ def test_show_dag_save(self, mock_render_dag): ) assert "File awesome.png saved" in out - @mock.patch("airflow.cli.commands.remote_commands.dag_command.subprocess.Popen") - @mock.patch("airflow.cli.commands.remote_commands.dag_command.render_dag") + @mock.patch("airflow.cli.commands.dag_command.subprocess.Popen") + @mock.patch("airflow.cli.commands.dag_command.render_dag") def test_show_dag_imgcat(self, mock_render_dag, mock_popen): mock_render_dag.return_value.pipe.return_value = b"DOT_DATA" mock_proc = mock.MagicMock() @@ -381,7 +381,7 @@ def test_pause(self): dag_command.dag_unpause(args) assert not DagModel.get_dagmodel("example_bash_operator").is_paused - @mock.patch("airflow.cli.commands.remote_commands.dag_command.ask_yesno") + @mock.patch("airflow.cli.commands.dag_command.ask_yesno") def test_pause_regex(self, mock_yesno): args = self.parser.parse_args(["dags", "pause", "^example_.*$", "--treat-dag-id-as-regex"]) dag_command.dag_pause(args) @@ -396,7 +396,7 @@ def test_pause_regex(self, mock_yesno): assert not DagModel.get_dagmodel("example_kubernetes_executor").is_paused assert not DagModel.get_dagmodel("example_xcom_args").is_paused - @mock.patch("airflow.cli.commands.remote_commands.dag_command.ask_yesno") + @mock.patch("airflow.cli.commands.dag_command.ask_yesno") def test_pause_regex_operation_cancelled(self, ask_yesno, capsys): args = self.parser.parse_args(["dags", "pause", "example_bash_operator", "--treat-dag-id-as-regex"]) ask_yesno.return_value = False @@ -404,7 +404,7 @@ def test_pause_regex_operation_cancelled(self, ask_yesno, capsys): stdout = capsys.readouterr().out assert "Operation cancelled by user" in stdout - @mock.patch("airflow.cli.commands.remote_commands.dag_command.ask_yesno") + @mock.patch("airflow.cli.commands.dag_command.ask_yesno") def test_pause_regex_yes(self, mock_yesno): args = self.parser.parse_args(["dags", "pause", ".*", "--treat-dag-id-as-regex", "--yes"]) dag_command.dag_pause(args) @@ -564,7 +564,7 @@ def test_dag_state(self): is None ) - @mock.patch("airflow.cli.commands.remote_commands.dag_command._parse_and_get_dag") + @mock.patch("airflow.cli.commands.dag_command._parse_and_get_dag") def test_dag_test(self, mock_parse_and_get_dag): cli_args = self.parser.parse_args(["dags", "test", "example_bash_operator", DEFAULT_DATE.isoformat()]) dag_command.dag_test(cli_args) @@ -583,7 +583,7 @@ def test_dag_test(self, mock_parse_and_get_dag): ] ) - @mock.patch("airflow.cli.commands.remote_commands.dag_command._parse_and_get_dag") + @mock.patch("airflow.cli.commands.dag_command._parse_and_get_dag") def test_dag_test_fail_raise_error(self, mock_parse_and_get_dag): logical_date_str = DEFAULT_DATE.isoformat() mock_parse_and_get_dag.return_value.test.return_value = DagRun( @@ -593,7 +593,7 @@ def test_dag_test_fail_raise_error(self, mock_parse_and_get_dag): with pytest.raises(SystemExit, match=r"DagRun failed"): dag_command.dag_test(cli_args) - @mock.patch("airflow.cli.commands.remote_commands.dag_command._parse_and_get_dag") + @mock.patch("airflow.cli.commands.dag_command._parse_and_get_dag") @mock.patch("airflow.utils.timezone.utcnow") def test_dag_test_no_logical_date(self, mock_utcnow, mock_parse_and_get_dag): now = pendulum.now() @@ -618,7 +618,7 @@ def test_dag_test_no_logical_date(self, mock_utcnow, mock_parse_and_get_dag): ] ) - @mock.patch("airflow.cli.commands.remote_commands.dag_command._parse_and_get_dag") + @mock.patch("airflow.cli.commands.dag_command._parse_and_get_dag") def test_dag_test_conf(self, mock_parse_and_get_dag): cli_args = self.parser.parse_args( [ @@ -646,10 +646,8 @@ def test_dag_test_conf(self, mock_parse_and_get_dag): ] ) - @mock.patch( - "airflow.cli.commands.remote_commands.dag_command.render_dag", return_value=MagicMock(source="SOURCE") - ) - @mock.patch("airflow.cli.commands.remote_commands.dag_command._parse_and_get_dag") + @mock.patch("airflow.cli.commands.dag_command.render_dag", return_value=MagicMock(source="SOURCE")) + @mock.patch("airflow.cli.commands.dag_command._parse_and_get_dag") def test_dag_test_show_dag(self, mock_parse_and_get_dag, mock_render_dag): mock_parse_and_get_dag.return_value.test.return_value.run_id = ( "__test_dag_test_show_dag_fake_dag_run_run_id__" diff --git a/airflow-core/tests/unit/cli/commands/local_commands/test_dag_processor_command.py b/airflow-core/tests/unit/cli/commands/test_dag_processor_command.py similarity index 88% rename from airflow-core/tests/unit/cli/commands/local_commands/test_dag_processor_command.py rename to airflow-core/tests/unit/cli/commands/test_dag_processor_command.py index 9a78d57c017f2..3e0e931587cd3 100644 --- a/airflow-core/tests/unit/cli/commands/local_commands/test_dag_processor_command.py +++ b/airflow-core/tests/unit/cli/commands/test_dag_processor_command.py @@ -23,7 +23,7 @@ import pytest from airflow.cli import cli_parser -from airflow.cli.commands.local_commands import dag_processor_command +from airflow.cli.commands import dag_processor_command from tests_common.test_utils.config import conf_vars @@ -40,7 +40,7 @@ def setup_class(cls): cls.parser = cli_parser.get_parser() @conf_vars({("core", "load_examples"): "False"}) - @mock.patch("airflow.cli.commands.local_commands.dag_processor_command.DagProcessorJobRunner") + @mock.patch("airflow.cli.commands.dag_processor_command.DagProcessorJobRunner") def test_start_job(self, mock_runner): """Ensure that DagProcessorJobRunner is started""" mock_runner.return_value.job_type = "DagProcessorJob" @@ -49,7 +49,7 @@ def test_start_job(self, mock_runner): mock_runner.return_value._execute.assert_called() @conf_vars({("core", "load_examples"): "False"}) - @mock.patch("airflow.cli.commands.local_commands.dag_processor_command.DagProcessorJobRunner") + @mock.patch("airflow.cli.commands.dag_processor_command.DagProcessorJobRunner") def test_bundle_names_passed(self, mock_runner, configure_testing_dag_bundle): mock_runner.return_value.job_type = "DagProcessorJob" args = self.parser.parse_args(["dag-processor", "--bundle-name", "testing"]) diff --git a/airflow-core/tests/unit/cli/commands/local_commands/test_db_command.py b/airflow-core/tests/unit/cli/commands/test_db_command.py similarity index 88% rename from airflow-core/tests/unit/cli/commands/local_commands/test_db_command.py rename to airflow-core/tests/unit/cli/commands/test_db_command.py index d1821f37dc12f..bc71b7b1d3d39 100644 --- a/airflow-core/tests/unit/cli/commands/local_commands/test_db_command.py +++ b/airflow-core/tests/unit/cli/commands/test_db_command.py @@ -25,7 +25,7 @@ from sqlalchemy.exc import OperationalError from airflow.cli import cli_parser -from airflow.cli.commands.local_commands import db_command +from airflow.cli.commands import db_command from airflow.exceptions import AirflowException pytestmark = pytest.mark.db_test @@ -36,18 +36,18 @@ class TestCliDb: def setup_class(cls): cls.parser = cli_parser.get_parser() - @mock.patch("airflow.cli.commands.local_commands.db_command.db.resetdb") + @mock.patch("airflow.cli.commands.db_command.db.resetdb") def test_cli_resetdb(self, mock_resetdb): db_command.resetdb(self.parser.parse_args(["db", "reset", "--yes"])) mock_resetdb.assert_called_once_with(skip_init=False) - @mock.patch("airflow.cli.commands.local_commands.db_command.db.resetdb") + @mock.patch("airflow.cli.commands.db_command.db.resetdb") def test_cli_resetdb_skip_init(self, mock_resetdb): db_command.resetdb(self.parser.parse_args(["db", "reset", "--yes", "--skip-init"])) mock_resetdb.assert_called_once_with(skip_init=True) - @mock.patch("airflow.cli.commands.local_commands.db_command.db.check_migrations") + @mock.patch("airflow.cli.commands.db_command.db.check_migrations") def test_cli_check_migrations(self, mock_wait_for_migrations): db_command.check_migrations(self.parser.parse_args(["db", "check-migrations"])) @@ -134,7 +134,7 @@ def test_cli_check_migrations(self, mock_wait_for_migrations): ), ], ) - @mock.patch("airflow.cli.commands.local_commands.db_command.db.upgradedb") + @mock.patch("airflow.cli.commands.db_command.db.upgradedb") def test_cli_upgrade_success(self, mock_upgradedb, args, called_with): # TODO(ephraimbuddy): Revisit this when we add more migration files and use other versions/revisions other than 2.10.0/22ed7efa9da2 db_command.migratedb(self.parser.parse_args(["db", "migrate", *args])) @@ -177,15 +177,15 @@ def test_cli_upgrade_success(self, mock_upgradedb, args, called_with): ), ], ) - @mock.patch("airflow.cli.commands.local_commands.db_command.db.upgradedb") + @mock.patch("airflow.cli.commands.db_command.db.upgradedb") def test_cli_sync_failure(self, mock_upgradedb, args, pattern): with pytest.raises(SystemExit, match=pattern): db_command.migratedb(self.parser.parse_args(["db", "migrate", *args])) - @mock.patch("airflow.cli.commands.local_commands.db_command.execute_interactive") - @mock.patch("airflow.cli.commands.local_commands.db_command.NamedTemporaryFile") + @mock.patch("airflow.cli.commands.db_command.execute_interactive") + @mock.patch("airflow.cli.commands.db_command.NamedTemporaryFile") @mock.patch( - "airflow.cli.commands.local_commands.db_command.settings.engine.url", + "airflow.cli.commands.db_command.settings.engine.url", make_url("mysql://root@mysql:3306/airflow"), ) def test_cli_shell_mysql(self, mock_tmp_file, mock_execute_interactive): @@ -197,10 +197,10 @@ def test_cli_shell_mysql(self, mock_tmp_file, mock_execute_interactive): b"\ndatabase = airflow" ) - @mock.patch("airflow.cli.commands.local_commands.db_command.execute_interactive") - @mock.patch("airflow.cli.commands.local_commands.db_command.NamedTemporaryFile") + @mock.patch("airflow.cli.commands.db_command.execute_interactive") + @mock.patch("airflow.cli.commands.db_command.NamedTemporaryFile") @mock.patch( - "airflow.cli.commands.local_commands.db_command.settings.engine.url", + "airflow.cli.commands.db_command.settings.engine.url", make_url("mysql://root@mysql/airflow"), ) def test_cli_shell_mysql_without_port(self, mock_tmp_file, mock_execute_interactive): @@ -212,18 +212,18 @@ def test_cli_shell_mysql_without_port(self, mock_tmp_file, mock_execute_interact b"\ndatabase = airflow" ) - @mock.patch("airflow.cli.commands.local_commands.db_command.execute_interactive") + @mock.patch("airflow.cli.commands.db_command.execute_interactive") @mock.patch( - "airflow.cli.commands.local_commands.db_command.settings.engine.url", + "airflow.cli.commands.db_command.settings.engine.url", make_url("sqlite:////root/airflow/airflow.db"), ) def test_cli_shell_sqlite(self, mock_execute_interactive): db_command.shell(self.parser.parse_args(["db", "shell"])) mock_execute_interactive.assert_called_once_with(["sqlite3", "/root/airflow/airflow.db"]) - @mock.patch("airflow.cli.commands.local_commands.db_command.execute_interactive") + @mock.patch("airflow.cli.commands.db_command.execute_interactive") @mock.patch( - "airflow.cli.commands.local_commands.db_command.settings.engine.url", + "airflow.cli.commands.db_command.settings.engine.url", make_url("postgresql+psycopg2://postgres:airflow@postgres:5432/airflow"), ) def test_cli_shell_postgres(self, mock_execute_interactive): @@ -240,9 +240,9 @@ def test_cli_shell_postgres(self, mock_execute_interactive): "PGUSER": "postgres", } - @mock.patch("airflow.cli.commands.local_commands.db_command.execute_interactive") + @mock.patch("airflow.cli.commands.db_command.execute_interactive") @mock.patch( - "airflow.cli.commands.local_commands.db_command.settings.engine.url", + "airflow.cli.commands.db_command.settings.engine.url", make_url("postgresql+psycopg2://postgres:airflow@postgres/airflow"), ) def test_cli_shell_postgres_without_port(self, mock_execute_interactive): @@ -260,7 +260,7 @@ def test_cli_shell_postgres_without_port(self, mock_execute_interactive): } @mock.patch( - "airflow.cli.commands.local_commands.db_command.settings.engine.url", + "airflow.cli.commands.db_command.settings.engine.url", make_url("invalid+psycopg2://postgres:airflow@postgres/airflow"), ) def test_cli_shell_invalid(self): @@ -323,7 +323,7 @@ def test_cli_downgrade_good(self, mock_dg, args, expected): ], ) @mock.patch("airflow.utils.db.downgrade") - @mock.patch("airflow.cli.commands.local_commands.db_command.input") + @mock.patch("airflow.cli.commands.db_command.input") def test_cli_downgrade_confirm(self, mock_input, mock_dg, resp, raise_): mock_input.return_value = resp if raise_: @@ -361,7 +361,7 @@ def setup_class(cls): cls.parser = cli_parser.get_parser() @pytest.mark.parametrize("timezone", ["UTC", "Europe/Berlin", "America/Los_Angeles"]) - @patch("airflow.cli.commands.local_commands.db_command.run_cleanup") + @patch("airflow.cli.commands.db_command.run_cleanup") def test_date_timezone_omitted(self, run_cleanup_mock, timezone): """ When timezone omitted we should always expect that the timestamp is @@ -381,7 +381,7 @@ def test_date_timezone_omitted(self, run_cleanup_mock, timezone): ) @pytest.mark.parametrize("timezone", ["UTC", "Europe/Berlin", "America/Los_Angeles"]) - @patch("airflow.cli.commands.local_commands.db_command.run_cleanup") + @patch("airflow.cli.commands.db_command.run_cleanup") def test_date_timezone_supplied(self, run_cleanup_mock, timezone): """ When tz included in the string then default timezone should not be used. @@ -401,7 +401,7 @@ def test_date_timezone_supplied(self, run_cleanup_mock, timezone): ) @pytest.mark.parametrize("confirm_arg, expected", [(["-y"], False), ([], True)]) - @patch("airflow.cli.commands.local_commands.db_command.run_cleanup") + @patch("airflow.cli.commands.db_command.run_cleanup") def test_confirm(self, run_cleanup_mock, confirm_arg, expected): """ When ``-y`` provided, ``confirm`` should be false. @@ -427,7 +427,7 @@ def test_confirm(self, run_cleanup_mock, confirm_arg, expected): ) @pytest.mark.parametrize("extra_arg, expected", [(["--skip-archive"], True), ([], False)]) - @patch("airflow.cli.commands.local_commands.db_command.run_cleanup") + @patch("airflow.cli.commands.db_command.run_cleanup") def test_skip_archive(self, run_cleanup_mock, extra_arg, expected): """ When ``--skip-archive`` provided, ``skip_archive`` should be True (False otherwise). @@ -453,7 +453,7 @@ def test_skip_archive(self, run_cleanup_mock, extra_arg, expected): ) @pytest.mark.parametrize("dry_run_arg, expected", [(["--dry-run"], True), ([], False)]) - @patch("airflow.cli.commands.local_commands.db_command.run_cleanup") + @patch("airflow.cli.commands.db_command.run_cleanup") def test_dry_run(self, run_cleanup_mock, dry_run_arg, expected): """ When tz included in the string then default timezone should not be used. @@ -481,7 +481,7 @@ def test_dry_run(self, run_cleanup_mock, dry_run_arg, expected): @pytest.mark.parametrize( "extra_args, expected", [(["--tables", "hello, goodbye"], ["hello", "goodbye"]), ([], None)] ) - @patch("airflow.cli.commands.local_commands.db_command.run_cleanup") + @patch("airflow.cli.commands.db_command.run_cleanup") def test_tables(self, run_cleanup_mock, extra_args, expected): """ When tz included in the string then default timezone should not be used. @@ -507,7 +507,7 @@ def test_tables(self, run_cleanup_mock, extra_args, expected): ) @pytest.mark.parametrize("extra_args, expected", [(["--verbose"], True), ([], False)]) - @patch("airflow.cli.commands.local_commands.db_command.run_cleanup") + @patch("airflow.cli.commands.db_command.run_cleanup") def test_verbose(self, run_cleanup_mock, extra_args, expected): """ When tz included in the string then default timezone should not be used. @@ -532,8 +532,8 @@ def test_verbose(self, run_cleanup_mock, extra_args, expected): skip_archive=False, ) - @patch("airflow.cli.commands.local_commands.db_command.export_archived_records") - @patch("airflow.cli.commands.local_commands.db_command.os.path.isdir", return_value=True) + @patch("airflow.cli.commands.db_command.export_archived_records") + @patch("airflow.cli.commands.db_command.os.path.isdir", return_value=True) def test_export_archived_records(self, os_mock, export_archived_mock): args = self.parser.parse_args( [ @@ -552,8 +552,8 @@ def test_export_archived_records(self, os_mock, export_archived_mock): @pytest.mark.parametrize( "extra_args, expected", [(["--tables", "hello, goodbye"], ["hello", "goodbye"]), ([], None)] ) - @patch("airflow.cli.commands.local_commands.db_command.export_archived_records") - @patch("airflow.cli.commands.local_commands.db_command.os.path.isdir", return_value=True) + @patch("airflow.cli.commands.db_command.export_archived_records") + @patch("airflow.cli.commands.db_command.os.path.isdir", return_value=True) def test_tables_in_export_archived_records_command( self, os_mock, export_archived_mock, extra_args, expected ): @@ -576,8 +576,8 @@ def test_tables_in_export_archived_records_command( ) @pytest.mark.parametrize("extra_args, expected", [(["--drop-archives"], True), ([], False)]) - @patch("airflow.cli.commands.local_commands.db_command.export_archived_records") - @patch("airflow.cli.commands.local_commands.db_command.os.path.isdir", return_value=True) + @patch("airflow.cli.commands.db_command.export_archived_records") + @patch("airflow.cli.commands.db_command.os.path.isdir", return_value=True) def test_drop_archives_in_export_archived_records_command( self, os_mock, export_archived_mock, extra_args, expected ): @@ -602,7 +602,7 @@ def test_drop_archives_in_export_archived_records_command( @pytest.mark.parametrize( "extra_args, expected", [(["--tables", "hello, goodbye"], ["hello", "goodbye"]), ([], None)] ) - @patch("airflow.cli.commands.local_commands.db_command.drop_archived_tables") + @patch("airflow.cli.commands.db_command.drop_archived_tables") def test_tables_in_drop_archived_records_command(self, mock_drop_archived_records, extra_args, expected): args = self.parser.parse_args( [ @@ -615,7 +615,7 @@ def test_tables_in_drop_archived_records_command(self, mock_drop_archived_record mock_drop_archived_records.assert_called_once_with(table_names=expected, needs_confirm=True) @pytest.mark.parametrize("extra_args, expected", [(["-y"], False), ([], True)]) - @patch("airflow.cli.commands.local_commands.db_command.drop_archived_tables") + @patch("airflow.cli.commands.db_command.drop_archived_tables") def test_confirm_in_drop_archived_records_command(self, mock_drop_archived_records, extra_args, expected): args = self.parser.parse_args( [ diff --git a/airflow-core/tests/unit/cli/commands/local_commands/test_info_command.py b/airflow-core/tests/unit/cli/commands/test_info_command.py similarity index 97% rename from airflow-core/tests/unit/cli/commands/local_commands/test_info_command.py rename to airflow-core/tests/unit/cli/commands/test_info_command.py index 634eee083b79a..1db61aa6346e2 100644 --- a/airflow-core/tests/unit/cli/commands/local_commands/test_info_command.py +++ b/airflow-core/tests/unit/cli/commands/test_info_command.py @@ -28,7 +28,7 @@ from rich.console import Console from airflow.cli import cli_parser -from airflow.cli.commands.local_commands import info_command +from airflow.cli.commands import info_command from airflow.config_templates import airflow_local_settings from airflow.logging_config import configure_logging from airflow.version import version as airflow_version @@ -185,7 +185,7 @@ class TestInfoCommandMockHttpx: } ) def test_show_info_anonymize_fileio(self, setup_parser, cleanup_providers_manager): - with mock.patch("airflow.cli.commands.local_commands.info_command.httpx.post") as post: + with mock.patch("airflow.cli.commands.info_command.httpx.post") as post: post.return_value = httpx.Response( status_code=200, json={ diff --git a/airflow-core/tests/unit/cli/commands/remote_commands/test_jobs_command.py b/airflow-core/tests/unit/cli/commands/test_jobs_command.py similarity index 99% rename from airflow-core/tests/unit/cli/commands/remote_commands/test_jobs_command.py rename to airflow-core/tests/unit/cli/commands/test_jobs_command.py index c97a62da80689..fa575e7917fd5 100644 --- a/airflow-core/tests/unit/cli/commands/remote_commands/test_jobs_command.py +++ b/airflow-core/tests/unit/cli/commands/test_jobs_command.py @@ -22,7 +22,7 @@ import pytest from airflow.cli import cli_parser -from airflow.cli.commands.remote_commands import jobs_command +from airflow.cli.commands import jobs_command from airflow.jobs.job import Job from airflow.jobs.scheduler_job_runner import SchedulerJobRunner from airflow.utils.session import create_session diff --git a/airflow-core/tests/unit/cli/commands/local_commands/test_kerberos_command.py b/airflow-core/tests/unit/cli/commands/test_kerberos_command.py similarity index 87% rename from airflow-core/tests/unit/cli/commands/local_commands/test_kerberos_command.py rename to airflow-core/tests/unit/cli/commands/test_kerberos_command.py index d99b4096c2f7a..39695ff51a857 100644 --- a/airflow-core/tests/unit/cli/commands/local_commands/test_kerberos_command.py +++ b/airflow-core/tests/unit/cli/commands/test_kerberos_command.py @@ -21,7 +21,7 @@ import pytest from airflow.cli import cli_parser -from airflow.cli.commands.local_commands import kerberos_command +from airflow.cli.commands import kerberos_command from airflow.security.kerberos import KerberosMode from tests_common.test_utils.config import conf_vars @@ -34,7 +34,7 @@ class TestKerberosCommand: def setup_class(cls): cls.parser = cli_parser.get_parser() - @mock.patch("airflow.cli.commands.local_commands.kerberos_command.krb") + @mock.patch("airflow.cli.commands.kerberos_command.krb") @conf_vars({("core", "executor"): "CeleryExecutor"}) def test_run_command(self, mock_krb): args = self.parser.parse_args(["kerberos", "PRINCIPAL", "--keytab", "/tmp/airflow.keytab"]) @@ -44,10 +44,10 @@ def test_run_command(self, mock_krb): keytab="/tmp/airflow.keytab", principal="PRINCIPAL", mode=KerberosMode.STANDARD ) - @mock.patch("airflow.cli.commands.local_commands.daemon_utils.TimeoutPIDLockFile") - @mock.patch("airflow.cli.commands.local_commands.daemon_utils.setup_locations") - @mock.patch("airflow.cli.commands.local_commands.daemon_utils.daemon") - @mock.patch("airflow.cli.commands.local_commands.kerberos_command.krb") + @mock.patch("airflow.cli.commands.daemon_utils.TimeoutPIDLockFile") + @mock.patch("airflow.cli.commands.daemon_utils.setup_locations") + @mock.patch("airflow.cli.commands.daemon_utils.daemon") + @mock.patch("airflow.cli.commands.kerberos_command.krb") @conf_vars({("core", "executor"): "CeleryExecutor"}) def test_run_command_daemon(self, mock_krb, mock_daemon, mock_setup_locations, mock_pid_file): mock_setup_locations.return_value = ( @@ -74,7 +74,7 @@ def test_run_command_daemon(self, mock_krb, mock_daemon, mock_setup_locations, m ] ) mock_open = mock.mock_open() - with mock.patch("airflow.cli.commands.local_commands.daemon_utils.open", mock_open): + with mock.patch("airflow.cli.commands.daemon_utils.open", mock_open): kerberos_command.kerberos(args) mock_krb.run.assert_called_once_with( @@ -112,7 +112,7 @@ def test_run_command_daemon(self, mock_krb, mock_daemon, mock_setup_locations, m mock.call().__exit__(None, None, None), ] - @mock.patch("airflow.cli.commands.local_commands.kerberos_command.krb") + @mock.patch("airflow.cli.commands.kerberos_command.krb") @conf_vars({("core", "executor"): "CeleryExecutor"}) def test_run_command_with_mode_standard(self, mock_krb): args = self.parser.parse_args(["kerberos", "PRINCIPAL", "--keytab", "/tmp/airflow.keytab"]) @@ -122,7 +122,7 @@ def test_run_command_with_mode_standard(self, mock_krb): keytab="/tmp/airflow.keytab", principal="PRINCIPAL", mode=KerberosMode.STANDARD ) - @mock.patch("airflow.cli.commands.local_commands.kerberos_command.krb") + @mock.patch("airflow.cli.commands.kerberos_command.krb") @conf_vars({("core", "executor"): "CeleryExecutor"}) def test_run_command_with_mode_one_time(self, mock_krb): args = self.parser.parse_args( diff --git a/airflow-core/tests/unit/cli/commands/test_legacy_commands.py b/airflow-core/tests/unit/cli/commands/test_legacy_commands.py index 8fb7df7efcce6..f4550146e4e52 100644 --- a/airflow-core/tests/unit/cli/commands/test_legacy_commands.py +++ b/airflow-core/tests/unit/cli/commands/test_legacy_commands.py @@ -24,8 +24,8 @@ import pytest from airflow.cli import cli_parser +from airflow.cli.commands import config_command from airflow.cli.commands.legacy_commands import check_legacy_command -from airflow.cli.commands.remote_commands import config_command class TestCliDeprecatedCommandsValue: diff --git a/airflow-core/tests/unit/cli/commands/local_commands/test_plugins_command.py b/airflow-core/tests/unit/cli/commands/test_plugins_command.py similarity index 97% rename from airflow-core/tests/unit/cli/commands/local_commands/test_plugins_command.py rename to airflow-core/tests/unit/cli/commands/test_plugins_command.py index 2621e39b9d332..abd3024d601fc 100644 --- a/airflow-core/tests/unit/cli/commands/local_commands/test_plugins_command.py +++ b/airflow-core/tests/unit/cli/commands/test_plugins_command.py @@ -24,7 +24,7 @@ import pytest from airflow.cli import cli_parser -from airflow.cli.commands.local_commands import plugins_command +from airflow.cli.commands import plugins_command from airflow.listeners.listener import get_listener_manager from airflow.plugins_manager import AirflowPlugin from airflow.sdk import BaseOperatorLink @@ -134,7 +134,7 @@ def test_should_display_one_plugins_as_table(self): """\ name | global_operator_extra_links ================+============================================================================== - test-plugin-cli | + test-plugin-cli | """ ) assert stdout == expected_output diff --git a/airflow-core/tests/unit/cli/commands/remote_commands/test_pool_command.py b/airflow-core/tests/unit/cli/commands/test_pool_command.py similarity index 99% rename from airflow-core/tests/unit/cli/commands/remote_commands/test_pool_command.py rename to airflow-core/tests/unit/cli/commands/test_pool_command.py index 8cd4731410247..67cc39dec4cab 100644 --- a/airflow-core/tests/unit/cli/commands/remote_commands/test_pool_command.py +++ b/airflow-core/tests/unit/cli/commands/test_pool_command.py @@ -25,7 +25,7 @@ from airflow import models, settings from airflow.cli import cli_parser -from airflow.cli.commands.remote_commands import pool_command +from airflow.cli.commands import pool_command from airflow.models import Pool from airflow.settings import Session from airflow.utils.db import add_default_pool_if_not_exists diff --git a/airflow-core/tests/unit/cli/commands/local_commands/test_rotate_fernet_key_command.py b/airflow-core/tests/unit/cli/commands/test_rotate_fernet_key_command.py similarity index 98% rename from airflow-core/tests/unit/cli/commands/local_commands/test_rotate_fernet_key_command.py rename to airflow-core/tests/unit/cli/commands/test_rotate_fernet_key_command.py index 7f124e2ca4648..5ec4502962ea4 100644 --- a/airflow-core/tests/unit/cli/commands/local_commands/test_rotate_fernet_key_command.py +++ b/airflow-core/tests/unit/cli/commands/test_rotate_fernet_key_command.py @@ -22,7 +22,7 @@ from cryptography.fernet import Fernet from airflow.cli import cli_parser -from airflow.cli.commands.local_commands import rotate_fernet_key_command +from airflow.cli.commands import rotate_fernet_key_command from airflow.hooks.base import BaseHook from airflow.models import Connection, Variable from airflow.utils.session import provide_session diff --git a/airflow-core/tests/unit/cli/commands/local_commands/test_scheduler_command.py b/airflow-core/tests/unit/cli/commands/test_scheduler_command.py similarity index 81% rename from airflow-core/tests/unit/cli/commands/local_commands/test_scheduler_command.py rename to airflow-core/tests/unit/cli/commands/test_scheduler_command.py index 8da375b2b1472..fc1ced044f540 100644 --- a/airflow-core/tests/unit/cli/commands/local_commands/test_scheduler_command.py +++ b/airflow-core/tests/unit/cli/commands/test_scheduler_command.py @@ -23,7 +23,7 @@ import pytest from airflow.cli import cli_parser -from airflow.cli.commands.local_commands import scheduler_command +from airflow.cli.commands import scheduler_command from airflow.executors import executor_loader from airflow.utils.scheduler_health import serve_health_check from airflow.utils.serve_logs import serve_logs @@ -47,8 +47,8 @@ def setup_class(cls): ("KubernetesExecutor", False), ], ) - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.SchedulerJobRunner") - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.Process") + @mock.patch("airflow.cli.commands.scheduler_command.SchedulerJobRunner") + @mock.patch("airflow.cli.commands.scheduler_command.Process") def test_serve_logs_on_scheduler(self, mock_process, mock_scheduler_job, executor, expect_serve_logs): mock_scheduler_job.return_value.job_type = "SchedulerJob" args = self.parser.parse_args(["scheduler"]) @@ -62,8 +62,8 @@ def test_serve_logs_on_scheduler(self, mock_process, mock_scheduler_job, executo with pytest.raises(AssertionError): mock_process.assert_has_calls([mock.call(target=serve_logs)]) - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.SchedulerJobRunner") - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.Process") + @mock.patch("airflow.cli.commands.scheduler_command.SchedulerJobRunner") + @mock.patch("airflow.cli.commands.scheduler_command.Process") @pytest.mark.parametrize("executor", ["LocalExecutor", "SequentialExecutor"]) def test_skip_serve_logs(self, mock_process, mock_scheduler_job, executor): mock_scheduler_job.return_value.job_type = "SchedulerJob" @@ -76,8 +76,8 @@ def test_skip_serve_logs(self, mock_process, mock_scheduler_job, executor): @mock.patch("airflow.utils.db.check_and_run_migrations") @mock.patch("airflow.utils.db.synchronize_log_template") - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.SchedulerJobRunner") - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.Process") + @mock.patch("airflow.cli.commands.scheduler_command.SchedulerJobRunner") + @mock.patch("airflow.cli.commands.scheduler_command.Process") def test_check_migrations_is_false(self, mock_process, mock_scheduler_job, mock_log, mock_run_migration): mock_scheduler_job.return_value.job_type = "SchedulerJob" args = self.parser.parse_args(["scheduler"]) @@ -88,8 +88,8 @@ def test_check_migrations_is_false(self, mock_process, mock_scheduler_job, mock_ @mock.patch("airflow.utils.db.check_and_run_migrations") @mock.patch("airflow.utils.db.synchronize_log_template") - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.SchedulerJobRunner") - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.Process") + @mock.patch("airflow.cli.commands.scheduler_command.SchedulerJobRunner") + @mock.patch("airflow.cli.commands.scheduler_command.Process") def test_check_migrations_is_true(self, mock_process, mock_scheduler_job, mock_log, mock_run_migration): mock_scheduler_job.return_value.job_type = "SchedulerJob" args = self.parser.parse_args(["scheduler"]) @@ -98,8 +98,8 @@ def test_check_migrations_is_true(self, mock_process, mock_scheduler_job, mock_l mock_run_migration.assert_called_once() mock_log.assert_called_once() - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.SchedulerJobRunner") - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.Process") + @mock.patch("airflow.cli.commands.scheduler_command.SchedulerJobRunner") + @mock.patch("airflow.cli.commands.scheduler_command.Process") @pytest.mark.parametrize("executor", ["LocalExecutor", "SequentialExecutor"]) def test_graceful_shutdown(self, mock_process, mock_scheduler_job, executor): mock_scheduler_job.return_value.job_type = "SchedulerJob" @@ -112,8 +112,8 @@ def test_graceful_shutdown(self, mock_process, mock_scheduler_job, executor): finally: mock_process().terminate.assert_called() - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.SchedulerJobRunner") - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.Process") + @mock.patch("airflow.cli.commands.scheduler_command.SchedulerJobRunner") + @mock.patch("airflow.cli.commands.scheduler_command.Process") def test_enable_scheduler_health(self, mock_process, mock_scheduler_job): with conf_vars({("scheduler", "enable_health_check"): "True"}): mock_scheduler_job.return_value.job_type = "SchedulerJob" @@ -121,8 +121,8 @@ def test_enable_scheduler_health(self, mock_process, mock_scheduler_job): scheduler_command.scheduler(args) mock_process.assert_has_calls([mock.call(target=serve_health_check)]) - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.SchedulerJobRunner") - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.Process") + @mock.patch("airflow.cli.commands.scheduler_command.SchedulerJobRunner") + @mock.patch("airflow.cli.commands.scheduler_command.Process") def test_disable_scheduler_health(self, mock_process, mock_scheduler_job): mock_scheduler_job.return_value.job_type = "SchedulerJob" args = self.parser.parse_args(["scheduler"]) @@ -146,10 +146,10 @@ def test_scheduler_health_host( serve_health_check() assert http_server_mock.call_args.args[0] == (health_check_host, health_check_port) - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.SchedulerJobRunner") - @mock.patch("airflow.cli.commands.local_commands.scheduler_command.Process") + @mock.patch("airflow.cli.commands.scheduler_command.SchedulerJobRunner") + @mock.patch("airflow.cli.commands.scheduler_command.Process") @mock.patch( - "airflow.cli.commands.local_commands.scheduler_command.run_job", + "airflow.cli.commands.scheduler_command.run_job", side_effect=Exception("run_job failed"), ) def test_run_job_exception_handling(self, mock_run_job, mock_process, mock_scheduler_job): diff --git a/airflow-core/tests/unit/cli/commands/local_commands/test_standalone_command.py b/airflow-core/tests/unit/cli/commands/test_standalone_command.py similarity index 96% rename from airflow-core/tests/unit/cli/commands/local_commands/test_standalone_command.py rename to airflow-core/tests/unit/cli/commands/test_standalone_command.py index 484596529f278..6151493ee6efa 100644 --- a/airflow-core/tests/unit/cli/commands/local_commands/test_standalone_command.py +++ b/airflow-core/tests/unit/cli/commands/test_standalone_command.py @@ -22,7 +22,7 @@ import pytest -from airflow.cli.commands.local_commands.standalone_command import StandaloneCommand +from airflow.cli.commands.standalone_command import StandaloneCommand from airflow.executors import executor_loader from airflow.executors.executor_constants import ( CELERY_EXECUTOR, diff --git a/airflow-core/tests/unit/cli/commands/remote_commands/test_task_command.py b/airflow-core/tests/unit/cli/commands/test_task_command.py similarity index 98% rename from airflow-core/tests/unit/cli/commands/remote_commands/test_task_command.py rename to airflow-core/tests/unit/cli/commands/test_task_command.py index 2ed3a60b3b6d0..57534bd978bf1 100644 --- a/airflow-core/tests/unit/cli/commands/remote_commands/test_task_command.py +++ b/airflow-core/tests/unit/cli/commands/test_task_command.py @@ -34,8 +34,8 @@ import pytest from airflow.cli import cli_parser -from airflow.cli.commands.remote_commands import task_command -from airflow.cli.commands.remote_commands.task_command import LoggerMutationHelper +from airflow.cli.commands import task_command +from airflow.cli.commands.task_command import LoggerMutationHelper from airflow.config_templates.airflow_local_settings import DEFAULT_LOGGING_CONFIG from airflow.configuration import conf from airflow.exceptions import DagRunNotFound @@ -137,9 +137,7 @@ def test_test_no_logical_date(self): assert "example_python_operator" in stdout.getvalue() assert "print_the_context" in stdout.getvalue() - @mock.patch( - "airflow.cli.commands.remote_commands.task_command.fetch_dag_run_from_run_id_or_logical_date_string" - ) + @mock.patch("airflow.cli.commands.task_command.fetch_dag_run_from_run_id_or_logical_date_string") def test_task_render_with_custom_timetable(self, mock_fetch_dag_run_from_run_id_or_logical_date_string): """ Test that the `tasks render` CLI command queries the database correctly diff --git a/airflow-core/tests/unit/cli/commands/local_commands/test_triggerer_command.py b/airflow-core/tests/unit/cli/commands/test_triggerer_command.py similarity index 81% rename from airflow-core/tests/unit/cli/commands/local_commands/test_triggerer_command.py rename to airflow-core/tests/unit/cli/commands/test_triggerer_command.py index 5f1f6afa35c1c..b5222038f2de5 100644 --- a/airflow-core/tests/unit/cli/commands/local_commands/test_triggerer_command.py +++ b/airflow-core/tests/unit/cli/commands/test_triggerer_command.py @@ -22,7 +22,7 @@ import pytest from airflow.cli import cli_parser -from airflow.cli.commands.local_commands import triggerer_command +from airflow.cli.commands import triggerer_command pytestmark = pytest.mark.db_test @@ -36,8 +36,8 @@ class TestTriggererCommand: def setup_class(cls): cls.parser = cli_parser.get_parser() - @mock.patch("airflow.cli.commands.local_commands.triggerer_command.TriggererJobRunner") - @mock.patch("airflow.cli.commands.local_commands.triggerer_command._serve_logs") + @mock.patch("airflow.cli.commands.triggerer_command.TriggererJobRunner") + @mock.patch("airflow.cli.commands.triggerer_command._serve_logs") def test_capacity_argument( self, mock_serve, @@ -51,9 +51,9 @@ def test_capacity_argument( mock_serve.return_value.__exit__.assert_called_once() mock_triggerer_job_runner.assert_called_once_with(job=mock.ANY, capacity=42) - @mock.patch("airflow.cli.commands.local_commands.triggerer_command.TriggererJobRunner") - @mock.patch("airflow.cli.commands.local_commands.triggerer_command.run_job") - @mock.patch("airflow.cli.commands.local_commands.triggerer_command.Process") + @mock.patch("airflow.cli.commands.triggerer_command.TriggererJobRunner") + @mock.patch("airflow.cli.commands.triggerer_command.run_job") + @mock.patch("airflow.cli.commands.triggerer_command.Process") def test_trigger_run_serve_logs(self, mock_process, mock_run_job, mock_trigger_job_runner): """Ensure that trigger runner and server log functions execute as intended""" triggerer_command.triggerer_run(False, 1, 10.3) diff --git a/airflow-core/tests/unit/cli/commands/remote_commands/test_variable_command.py b/airflow-core/tests/unit/cli/commands/test_variable_command.py similarity index 99% rename from airflow-core/tests/unit/cli/commands/remote_commands/test_variable_command.py rename to airflow-core/tests/unit/cli/commands/test_variable_command.py index a03f99940b056..1d86b1068d500 100644 --- a/airflow-core/tests/unit/cli/commands/remote_commands/test_variable_command.py +++ b/airflow-core/tests/unit/cli/commands/test_variable_command.py @@ -27,7 +27,7 @@ from airflow import models from airflow.cli import cli_parser -from airflow.cli.commands.remote_commands import variable_command +from airflow.cli.commands import variable_command from airflow.models import Variable from airflow.utils.session import create_session diff --git a/airflow-core/tests/unit/cli/commands/remote_commands/test_version_command.py b/airflow-core/tests/unit/cli/commands/test_version_command.py similarity index 87% rename from airflow-core/tests/unit/cli/commands/remote_commands/test_version_command.py rename to airflow-core/tests/unit/cli/commands/test_version_command.py index 1aa17828bfa5d..bcf2e303c1fd3 100644 --- a/airflow-core/tests/unit/cli/commands/remote_commands/test_version_command.py +++ b/airflow-core/tests/unit/cli/commands/test_version_command.py @@ -19,7 +19,7 @@ from contextlib import redirect_stdout from io import StringIO -import airflow.cli.commands.remote_commands.version_command +import airflow.cli.commands.version_command from airflow.cli import cli_parser from airflow.version import version @@ -31,5 +31,5 @@ def setup_class(cls): def test_cli_version(self): with redirect_stdout(StringIO()) as stdout: - airflow.cli.commands.remote_commands.version_command.version(self.parser.parse_args(["version"])) + airflow.cli.commands.version_command.version(self.parser.parse_args(["version"])) assert version in stdout.getvalue() diff --git a/airflow-core/tests/unit/listeners/file_write_listener.py b/airflow-core/tests/unit/listeners/file_write_listener.py index c542ccacab5b3..660412f464c66 100644 --- a/airflow-core/tests/unit/listeners/file_write_listener.py +++ b/airflow-core/tests/unit/listeners/file_write_listener.py @@ -19,7 +19,7 @@ import logging -from airflow.cli.commands.remote_commands.task_command import TaskCommandMarker +from airflow.cli.commands.task_command import TaskCommandMarker from airflow.listeners import hookimpl log = logging.getLogger(__name__) diff --git a/providers/celery/src/airflow/providers/celery/cli/celery_command.py b/providers/celery/src/airflow/providers/celery/cli/celery_command.py index 8381886f70240..e65f924f5a167 100644 --- a/providers/celery/src/airflow/providers/celery/cli/celery_command.py +++ b/providers/celery/src/airflow/providers/celery/cli/celery_command.py @@ -47,10 +47,8 @@ def _run_command_with_daemon_option(*args, **kwargs): try: - if AIRFLOW_V_3_0_PLUS: - from airflow.cli.commands.local_commands.daemon_utils import run_command_with_daemon_option - else: - from airflow.cli.commands.daemon_utils import run_command_with_daemon_option + from airflow.cli.commands.daemon_utils import run_command_with_daemon_option + run_command_with_daemon_option(*args, **kwargs) except ImportError: from airflow.exceptions import AirflowOptionalProviderFeatureException diff --git a/providers/celery/tests/unit/celery/cli/test_celery_command.py b/providers/celery/tests/unit/celery/cli/test_celery_command.py index 06f96876a1f61..b10a7afa12681 100644 --- a/providers/celery/tests/unit/celery/cli/test_celery_command.py +++ b/providers/celery/tests/unit/celery/cli/test_celery_command.py @@ -278,7 +278,7 @@ def _test_run_command_daemon(self, mock_celery_app, mock_daemon, mock_setup_loca ] ) mock_open = mock.mock_open() - with mock.patch("airflow.cli.commands.local_commands.daemon_utils.open", mock_open): + with mock.patch("airflow.cli.commands.daemon_utils.open", mock_open): celery_command.flower(args) mock_celery_app.start.assert_called_once_with( @@ -344,9 +344,9 @@ def test_run_command_daemon_v_3_below( self._test_run_command_daemon(mock_celery_app, mock_daemon, mock_setup_locations, mock_pid_file) @pytest.mark.skipif(not AIRFLOW_V_3_0_PLUS, reason="Test requires Airflow 3.0+") - @mock.patch("airflow.cli.commands.local_commands.daemon_utils.TimeoutPIDLockFile") - @mock.patch("airflow.cli.commands.local_commands.daemon_utils.setup_locations") - @mock.patch("airflow.cli.commands.local_commands.daemon_utils.daemon") + @mock.patch("airflow.cli.commands.daemon_utils.TimeoutPIDLockFile") + @mock.patch("airflow.cli.commands.daemon_utils.setup_locations") + @mock.patch("airflow.cli.commands.daemon_utils.daemon") @mock.patch("airflow.providers.celery.executors.celery_executor.app") def test_run_command_daemon_v3_above( self, mock_celery_app, mock_daemon, mock_setup_locations, mock_pid_file diff --git a/providers/fab/src/airflow/providers/fab/auth_manager/cli_commands/db_command.py b/providers/fab/src/airflow/providers/fab/auth_manager/cli_commands/db_command.py index d6d019ab20320..38d2617f78f37 100644 --- a/providers/fab/src/airflow/providers/fab/auth_manager/cli_commands/db_command.py +++ b/providers/fab/src/airflow/providers/fab/auth_manager/cli_commands/db_command.py @@ -17,7 +17,7 @@ from __future__ import annotations from airflow import settings -from airflow.cli.commands.local_commands.db_command import run_db_downgrade_command, run_db_migrate_command +from airflow.cli.commands.db_command import run_db_downgrade_command, run_db_migrate_command from airflow.providers.fab.auth_manager.models.db import _REVISION_HEADS_MAP, FABDBManager from airflow.utils import cli as cli_utils from airflow.utils.providers_configuration_loader import providers_configuration_loaded diff --git a/scripts/in_container/run_provider_yaml_files_check.py b/scripts/in_container/run_provider_yaml_files_check.py index 1d17a8422c62e..3f9a3671fc1ed 100755 --- a/scripts/in_container/run_provider_yaml_files_check.py +++ b/scripts/in_container/run_provider_yaml_files_check.py @@ -40,7 +40,7 @@ from rich.console import Console from tabulate import tabulate -from airflow.cli.commands.local_commands.info_command import Architecture +from airflow.cli.commands.info_command import Architecture from airflow.exceptions import AirflowProviderDeprecationWarning from airflow.providers_manager import ProvidersManager From 7e91bb0ec517ed1845a9e028b9fb02d71d11a699 Mon Sep 17 00:00:00 2001 From: Jed Cunningham Date: Mon, 24 Mar 2025 22:08:47 -0600 Subject: [PATCH 2/3] Fix test --- airflow-core/tests/unit/cli/commands/test_plugins_command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow-core/tests/unit/cli/commands/test_plugins_command.py b/airflow-core/tests/unit/cli/commands/test_plugins_command.py index abd3024d601fc..1f7278d90912f 100644 --- a/airflow-core/tests/unit/cli/commands/test_plugins_command.py +++ b/airflow-core/tests/unit/cli/commands/test_plugins_command.py @@ -133,7 +133,7 @@ def test_should_display_one_plugins_as_table(self): expected_output = textwrap.dedent( """\ name | global_operator_extra_links - ================+============================================================================== + ================+=============================================================== test-plugin-cli | """ ) From f8792281c2b49043770de1346ac5364ab73ac158 Mon Sep 17 00:00:00 2001 From: Jed Cunningham Date: Tue, 25 Mar 2025 12:26:29 -0600 Subject: [PATCH 3/3] Missed a spot --- scripts/cov/cli_coverage.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/cov/cli_coverage.py b/scripts/cov/cli_coverage.py index 46dcd0607a52e..ca85d2e41ea15 100644 --- a/scripts/cov/cli_coverage.py +++ b/scripts/cov/cli_coverage.py @@ -30,20 +30,20 @@ files_not_fully_covered = [ "airflow/cli/cli_config.py", "airflow/cli/cli_parser.py", - "airflow/cli/commands/remote_commands/config_command.py", - "airflow/cli/commands/remote_commands/connection_command.py", - "airflow/cli/commands/remote_commands/dag_command.py", - "airflow/cli/commands/local_commands/dag_processor_command.py", - "airflow/cli/commands/local_commands/db_command.py", - "airflow/cli/commands/local_commands/info_command.py", - "airflow/cli/commands/remote_commands/jobs_command.py", - "airflow/cli/commands/local_commands/plugins_command.py", - "airflow/cli/commands/remote_commands/pool_command.py", - "airflow/cli/commands/remote_commands/provider_command.py", - "airflow/cli/commands/local_commands/scheduler_command.py", - "airflow/cli/commands/local_commands/standalone_command.py", - "airflow/cli/commands/remote_commands/task_command.py", - "airflow/cli/commands/remote_commands/variable_command.py", + "airflow/cli/commands/config_command.py", + "airflow/cli/commands/connection_command.py", + "airflow/cli/commands/dag_command.py", + "airflow/cli/commands/dag_processor_command.py", + "airflow/cli/commands/db_command.py", + "airflow/cli/commands/info_command.py", + "airflow/cli/commands/jobs_command.py", + "airflow/cli/commands/plugins_command.py", + "airflow/cli/commands/pool_command.py", + "airflow/cli/commands/provider_command.py", + "airflow/cli/commands/scheduler_command.py", + "airflow/cli/commands/standalone_command.py", + "airflow/cli/commands/task_command.py", + "airflow/cli/commands/variable_command.py", "airflow/cli/simple_table.py", ]