Skip to content

[AIRFLOW-5731] Make output format from list commands configurable#6400

Merged
kaxil merged 1 commit into
apache:masterfrom
sekikn:AIRFLOW-5731
Oct 28, 2019
Merged

[AIRFLOW-5731] Make output format from list commands configurable#6400
kaxil merged 1 commit into
apache:masterfrom
sekikn:AIRFLOW-5731

Conversation

@sekikn
Copy link
Copy Markdown
Contributor

@sekikn sekikn commented Oct 24, 2019

Make sure you have checked all steps below.

Jira

  • My PR addresses the following Airflow Jira issues and references them in the PR title. For example, "[AIRFLOW-XXX] My Airflow PR"
    • https://issues.apache.org/jira/browse/AIRFLOW-5731
    • In case you are fixing a typo in the documentation you can prepend your commit with [AIRFLOW-XXX], code changes always need a Jira issue.
    • In case you are proposing a fundamental code change, you need to create an Airflow Improvement Proposal (AIP).
    • In case you are adding a dependency, check if the license complies with the ASF 3rd Party License Policy.

Description

  • Here are some details about my PR, including screenshots of any UI changes:

Currently, list commands such as airflow connections list and airflow users list display prettily formatted tables, but they are not so suitable for parsing and processing. With this PR, users can get easier-to-parse output, as follows:

$ airflow connections list --tablefmt=simple 2>/dev/null | head
Conn Id                         Conn Type                    Host                       Port    Is Encrypted    Is Extra Encrypted    Extra
------------------------------  ---------------------------  -------------------------  ------  --------------  --------------------  ------------------------------
'airflow_db'                    'mysql'                      'mysql'                    None    False           False                 None
'local_mysql'                   'mysql'                      'localhost'                None    True            False                 None
'presto_default'                'presto'                     'localhost'                3400    False           False                 None
'google_cloud_default'          'google_cloud_platform'      None                       None    False           False                 None
'hive_cli_default'              'hive_cli'                   'localhost'                10000   False           True                  'gAAAAABdrxCP...jMAQ6LknDM8pc'
'pig_cli_default'               'pig_cli'                    None                       None    False           False                 None
'hiveserver2_default'           'hiveserver2'                'localhost'                10000   False           False                 None
'metastore_default'             'hive_metastore'             'localhost'                9083    False           True                  'gAAAAABdrxCP...ABWevIJL-Dto='

$ airflow connections list --tablefmt=tsv 2>/dev/null | head
Conn Id                       	Conn Type                  	Host                     	Port  	Is Encrypted  	Is Extra Encrypted  	Extra
'airflow_db'                  	'mysql'                    	'mysql'                  	None  	False         	False               	None
'local_mysql'                 	'mysql'                    	'localhost'              	None  	True          	False               	None
'presto_default'              	'presto'                   	'localhost'              	3400  	False         	False               	None
'google_cloud_default'        	'google_cloud_platform'    	None                     	None  	False         	False               	None
'hive_cli_default'            	'hive_cli'                 	'localhost'              	10000 	False         	True                	'gAAAAABdrxCP...jMAQ6LknDM8pc'
'pig_cli_default'             	'pig_cli'                  	None                     	None  	False         	False               	None
'hiveserver2_default'         	'hiveserver2'              	'localhost'              	10000 	False         	False               	None
'metastore_default'           	'hive_metastore'           	'localhost'              	9083  	False         	True                	'gAAAAABdrxCP...ABWevIJL-Dto='
'mongo_default'               	'mongo'                    	'mongo'                  	27017 	False         	False               	None

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:

test_cli_list_users_with_args
test_cli_list_roles_with_args
test_cli_list_jobs_with_args (added arguments to the existing test)
test_cli_connections_list_with_args
test_pool_list
test_pool_list_with_args

Commits

  • My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Documentation

  • In case of new functionality, my PR adds documentation that describes how to use it.
    • All the public functions and the classes in the PR contain docstrings that explain what it does
    • If you implement backwards incompatible changes, please leave a note in the Updating.md so we can assign it to a appropriate release

@BasPH
Copy link
Copy Markdown
Contributor

BasPH commented Oct 24, 2019

I'm all in for supporting different output formats with the CLI. Looking at other CLIs such as:

they have arguments named "output" or "format", which I would also like to have. Could you rename the argument to "output"?

Currently, list commands such as `airflow connections list` and `airflow
users list` display prettily formatted tables, but they are not so
suitable for parsing and processing. This PR enables users to specify
their output format such as `--output=tsv`.
@sekikn
Copy link
Copy Markdown
Contributor Author

sekikn commented Oct 24, 2019

@BasPH Thanks for the comment! Just updated the PR.

@kaxil kaxil merged commit ee0a557 into apache:master Oct 28, 2019
@kaxil
Copy link
Copy Markdown
Member

kaxil commented Oct 28, 2019

Good to see your contributions again @sekikn :)

@sekikn
Copy link
Copy Markdown
Contributor Author

sekikn commented Oct 29, 2019

Thanks @kaxil! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants