ashb commented on a change in pull request #4821: [AIRFLOW-3998] Use nested
commands in cli.
URL: https://github.com/apache/airflow/pull/4821#discussion_r275442777
##########
File path: airflow/bin/cli.py
##########
@@ -258,38 +259,57 @@ def delete_dag(args):
print("Bail.")
+def _tabulate_pools(pools):
+ return "\n%s" % tabulate(pools, ['Pool', 'Slots', 'Description'],
+ tablefmt="fancy_grid")
+
+
@cli_utils.action_logging
-def pool(args):
+def pool_list(args):
log = LoggingMixin().log
+ pools = api_client.get_pools()
+ log.info(_tabulate_pools(pools=pools))
- def _tabulate(pools):
- return "\n%s" % tabulate(pools, ['Pool', 'Slots', 'Description'],
- tablefmt="fancy_grid")
- try:
- imp = getattr(args, 'import')
- if args.get is not None:
- pools = [api_client.get_pool(name=args.get)]
- elif args.set:
- pools = [api_client.create_pool(name=args.set[0],
- slots=args.set[1],
- description=args.set[2])]
- elif args.delete:
- pools = [api_client.delete_pool(name=args.delete)]
- elif imp:
- if os.path.exists(imp):
- pools = pool_import_helper(imp)
- else:
- print("Missing pools file.")
- pools = api_client.get_pools()
- elif args.export:
- pools = pool_export_helper(args.export)
- else:
- pools = api_client.get_pools()
- except (AirflowException, IOError) as err:
- log.error(err)
+@cli_utils.action_logging
Review comment:
list/get etc don't need this decorator, only things that modify state should
have it (this wasn't possible before)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services