Skip to content

Commit

Permalink
Unify command names in CLI (apache#10669)
Browse files Browse the repository at this point in the history
* Unify command names in CLI
  • Loading branch information
mik-laj authored Sep 2, 2020
1 parent 9108cb5 commit 0d9e421
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 50 deletions.
4 changes: 2 additions & 2 deletions IMAGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,9 @@ The PROD image entrypoint works as follows:
info Show information about current Airflow and environment
kerberos Start a kerberos ticket renewer
plugins Dump information about loaded plugins
rotate_fernet_key Rotate encrypted connection credentials and variables
rotate-fernet-key Rotate encrypted connection credentials and variables
scheduler Start a scheduler instance
sync_perm Update permissions for existing roles and DAGs
sync-perm Update permissions for existing roles and DAGs
version Show the version
webserver Start a Airflow webserver instance
Expand Down
61 changes: 32 additions & 29 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,35 +222,38 @@ For a complete list of updated CLI commands, see https://airflow.apache.org/cli.
You can learn about the commands by running ``airflow --help``. For example to get help about the ``celery`` group command,
you have to run the help command: ``airflow celery --help``.

| Old command | New command | Group |
|-----------------------------|------------------------------------|--------------------|
| ``airflow worker`` | ``airflow celery worker`` | ``celery`` |
| ``airflow flower`` | ``airflow celery flower`` | ``celery`` |
| ``airflow trigger_dag`` | ``airflow dags trigger`` | ``dags`` |
| ``airflow delete_dag`` | ``airflow dags delete`` | ``dags`` |
| ``airflow show_dag`` | ``airflow dags show`` | ``dags`` |
| ``airflow list_dag`` | ``airflow dags list`` | ``dags`` |
| ``airflow dag_status`` | ``airflow dags status`` | ``dags`` |
| ``airflow backfill`` | ``airflow dags backfill`` | ``dags`` |
| ``airflow list_dag_runs`` | ``airflow dags list_runs`` | ``dags`` |
| ``airflow pause`` | ``airflow dags pause`` | ``dags`` |
| ``airflow unpause`` | ``airflow dags unpause`` | ``dags`` |
| ``airflow test`` | ``airflow tasks test`` | ``tasks`` |
| ``airflow clear`` | ``airflow tasks clear`` | ``tasks`` |
| ``airflow list_tasks`` | ``airflow tasks list`` | ``tasks`` |
| ``airflow task_failed_deps``| ``airflow tasks failed_deps`` | ``tasks`` |
| ``airflow task_state`` | ``airflow tasks state`` | ``tasks`` |
| ``airflow run`` | ``airflow tasks run`` | ``tasks`` |
| ``airflow render`` | ``airflow tasks render`` | ``tasks`` |
| ``airflow initdb`` | ``airflow db init`` | ``db`` |
| ``airflow resetdb`` | ``airflow db reset`` | ``db`` |
| ``airflow upgradedb`` | ``airflow db upgrade`` | ``db`` |
| ``airflow checkdb`` | ``airflow db check`` | ``db`` |
| ``airflow shell`` | ``airflow db shell`` | ``db`` |
| ``airflow pool`` | ``airflow pools`` | ``pools`` |
| ``airflow create_user`` | ``airflow users create`` | ``users`` |
| ``airflow delete_user`` | ``airflow users delete`` | ``users`` |
| ``airflow list_users`` | ``airflow users list`` | ``users`` |
| Old command | New command | Group |
|-------------------------------|------------------------------------|--------------------|
| ``airflow worker`` | ``airflow celery worker`` | ``celery`` |
| ``airflow flower`` | ``airflow celery flower`` | ``celery`` |
| ``airflow trigger_dag`` | ``airflow dags trigger`` | ``dags`` |
| ``airflow delete_dag`` | ``airflow dags delete`` | ``dags`` |
| ``airflow show_dag`` | ``airflow dags show`` | ``dags`` |
| ``airflow list_dag`` | ``airflow dags list`` | ``dags`` |
| ``airflow dag_status`` | ``airflow dags status`` | ``dags`` |
| ``airflow backfill`` | ``airflow dags backfill`` | ``dags`` |
| ``airflow list_dag_runs`` | ``airflow dags list-runs`` | ``dags`` |
| ``airflow pause`` | ``airflow dags pause`` | ``dags`` |
| ``airflow unpause`` | ``airflow dags unpause`` | ``dags`` |
| ``airflow test`` | ``airflow tasks test`` | ``tasks`` |
| ``airflow clear`` | ``airflow tasks clear`` | ``tasks`` |
| ``airflow list_tasks`` | ``airflow tasks list`` | ``tasks`` |
| ``airflow task_failed_deps`` | ``airflow tasks failed-deps`` | ``tasks`` |
| ``airflow task_state`` | ``airflow tasks state`` | ``tasks`` |
| ``airflow run`` | ``airflow tasks run`` | ``tasks`` |
| ``airflow render`` | ``airflow tasks render`` | ``tasks`` |
| ``airflow initdb`` | ``airflow db init`` | ``db`` |
| ``airflow resetdb`` | ``airflow db reset`` | ``db`` |
| ``airflow upgradedb`` | ``airflow db upgrade`` | ``db`` |
| ``airflow checkdb`` | ``airflow db check`` | ``db`` |
| ``airflow shell`` | ``airflow db shell`` | ``db`` |
| ``airflow pool`` | ``airflow pools`` | ``pools`` |
| ``airflow create_user`` | ``airflow users create`` | ``users`` |
| ``airflow delete_user`` | ``airflow users delete`` | ``users`` |
| ``airflow list_users`` | ``airflow users list`` | ``users`` |
| ``airflow rotate_fernet_key`` | ``airflow rotate-fernet-key`` | |
| ``airflow sync_perm`` | ``airflow sync-perm`` | |



Example Usage for the ``users`` group:
Expand Down
16 changes: 8 additions & 8 deletions airflow/cli/cli_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ class GroupCommand(NamedTuple):
args=(ARG_SUBDIR, ARG_OUTPUT),
),
ActionCommand(
name='list_runs',
name='list-runs',
help="List DAG runs given a DAG id",
description=(
"List DAG runs given a DAG id. If state option is given, it will only search for all the "
Expand All @@ -798,7 +798,7 @@ class GroupCommand(NamedTuple):
args=(ARG_DAG_ID_OPT, ARG_NO_BACKFILL, ARG_STATE, ARG_OUTPUT, ARG_START_DATE, ARG_END_DATE),
),
ActionCommand(
name='list_jobs',
name='list-jobs',
help="List the jobs",
func=lazy_load_command('airflow.cli.commands.dag_command.dag_list_jobs'),
args=(ARG_DAG_ID_OPT, ARG_STATE, ARG_LIMIT, ARG_OUTPUT,),
Expand Down Expand Up @@ -932,7 +932,7 @@ class GroupCommand(NamedTuple):
args=(ARG_DAG_ID, ARG_TASK_ID, ARG_EXECUTION_DATE, ARG_SUBDIR),
),
ActionCommand(
name='failed_deps',
name='failed-deps',
help="Returns the unmet dependencies for a task instance",
description=(
"Returns the unmet dependencies for a task instance from the perspective of the scheduler. "
Expand Down Expand Up @@ -973,7 +973,7 @@ class GroupCommand(NamedTuple):
),
),
ActionCommand(
name='states_for_dag_run',
name='states-for-dag-run',
help="Get the status of all task instances in a dag run",
func=lazy_load_command('airflow.cli.commands.task_command.task_states_for_dag_run'),
args=(ARG_DAG_ID, ARG_EXECUTION_DATE, ARG_OUTPUT),
Expand Down Expand Up @@ -1172,13 +1172,13 @@ class GroupCommand(NamedTuple):
args=(ARG_USERNAME,),
),
ActionCommand(
name='add_role',
name='add-role',
help='Add role to a user',
func=lazy_load_command('airflow.cli.commands.user_command.add_role'),
args=(ARG_USERNAME_OPTIONAL, ARG_EMAIL_OPTIONAL, ARG_ROLE),
),
ActionCommand(
name='remove_role',
name='remove-role',
help='Remove role from a user',
func=lazy_load_command('airflow.cli.commands.user_command.remove_role'),
args=(ARG_USERNAME_OPTIONAL, ARG_EMAIL_OPTIONAL, ARG_ROLE),
Expand Down Expand Up @@ -1333,13 +1333,13 @@ class GroupCommand(NamedTuple):
subcommands=ROLES_COMMANDS,
),
ActionCommand(
name='sync_perm',
name='sync-perm',
help="Update permissions for existing roles and DAGs",
func=lazy_load_command('airflow.cli.commands.sync_perm_command.sync_perm'),
args=(),
),
ActionCommand(
name='rotate_fernet_key',
name='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=(
Expand Down
4 changes: 2 additions & 2 deletions airflow/cli/commands/legacy_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
"list_dag": "dags list",
"dag_status": "dags status",
"backfill": "dags backfill",
"list_dag_runs": "dags list_runs",
"list_dag_runs": "dags list-runs",
"pause": "dags pause",
"unpause": "dags unpause",
"test": "tasks test",
"clear": "tasks clear",
"list_tasks": "tasks list",
"task_failed_deps": "tasks failed_deps",
"task_failed_deps": "tasks failed-deps",
"task_state": "tasks state",
"run": "tasks run",
"render": "tasks render",
Expand Down
2 changes: 1 addition & 1 deletion airflow/cli/commands/task_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def task_failed_deps(args):
Returns the unmet dependencies for a task instance from the perspective of the
scheduler (i.e. why a task instance doesn't get scheduled and then queued by the
scheduler, and then run by an executor).
>>> airflow tasks failed_deps tutorial sleep 2015-01-01
>>> airflow tasks failed-deps tutorial sleep 2015-01-01
Task instance dependencies not met:
Dagrun Running: Task instance's dagrun did not exist: Unknown reason
Trigger Rule: Task's trigger rule 'all_success' requires all upstream tasks
Expand Down
2 changes: 1 addition & 1 deletion docs/security/secrets/fernet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Once connection credentials and variables have been encrypted using a fernet
key, changing the key will cause decryption of existing credentials to fail. To
rotate the fernet key without invalidating existing encrypted values, prepend
the new key to the ``fernet_key`` setting, run
``airflow rotate_fernet_key``, and then drop the original key from
``airflow rotate-fernet-key``, and then drop the original key from
``fernet_keys``:

#. Set ``fernet_key`` to ``new_fernet_key,old_fernet_key``
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/commands/test_dag_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def test_cli_list_dag_runs(self):
dag_command.dag_trigger(self.parser.parse_args([
'dags', 'trigger', 'example_bash_operator', ]))
args = self.parser.parse_args(['dags',
'list_runs',
'list-runs',
'--dag-id',
'example_bash_operator',
'--no-backfill',
Expand All @@ -351,7 +351,7 @@ def test_cli_list_dag_runs(self):
dag_command.dag_list_dag_runs(args)

def test_cli_list_jobs_with_args(self):
args = self.parser.parse_args(['dags', 'list_jobs', '--dag-id',
args = self.parser.parse_args(['dags', 'list-jobs', '--dag-id',
'example_bash_operator',
'--state', 'success',
'--limit', '100',
Expand Down Expand Up @@ -415,7 +415,7 @@ def test_delete_dag_existing_file(self):
self.assertEqual(session.query(DM).filter_by(dag_id=key).count(), 0)

def test_cli_list_jobs(self):
args = self.parser.parse_args(['dags', 'list_jobs'])
args = self.parser.parse_args(['dags', 'list-jobs'])
dag_command.dag_list_jobs(args)

def test_dag_state(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/commands/test_sync_perm_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_cli_sync_perm(self, dagbag_mock, mock_cached_app):
appbuilder.sm = mock.Mock()

args = self.parser.parse_args([
'sync_perm'
'sync-perm'
])
sync_perm_command.sync_perm(args)

Expand Down
2 changes: 1 addition & 1 deletion tests/cli/commands/test_task_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_task_states_for_dag_run(self):

with redirect_stdout(io.StringIO()) as stdout:
task_command.task_states_for_dag_run(self.parser.parse_args([
'tasks', 'states_for_dag_run', 'example_python_operator', defaut_date2.isoformat()]))
'tasks', 'states-for-dag-run', 'example_python_operator', defaut_date2.isoformat()]))
actual_out = stdout.getvalue()

formatted_rows = [('example_python_operator',
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/commands/test_user_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def test_cli_add_user_role(self):
)

args = self.parser.parse_args([
'users', 'add_role', '--username', 'test4', '--role', 'Op'
'users', 'add-role', '--username', 'test4', '--role', 'Op'
])
user_command.users_manage_role(args, remove=False)

Expand All @@ -242,7 +242,7 @@ def test_cli_remove_user_role(self):
)

args = self.parser.parse_args([
'users', 'remove_role', '--username', 'test4', '--role', 'Viewer'
'users', 'remove-role', '--username', 'test4', '--role', 'Viewer'
])
user_command.users_manage_role(args, remove=True)

Expand Down

0 comments on commit 0d9e421

Please sign in to comment.