You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@airflow.apache.org by Iuliia Volkova <xn...@gmail.com> on 2018/11/18 11:08:01 UTC

Refactor Airflow Cli for version Airflow 2.0

Hi, dev-list! Hi, maintainers! I want to pick up a theme about refactoring
the  Airflow Cli (
https://github.com/apache/incubator-airflow/blob/master/airflow/bin/cli.py)
for version 2.0. I want to initiate it for:

- to move utility functions in a separate module (already exist
airflow.utils.cli - maybe make sense use this module). I talk about methods
that do not generate commands or parse args. Usually, also, they are used
in two or more commands, for example,
https://github.com/apache/incubator-airflow/blob/master/airflow/bin/cli.py#L121
.

- to use Command Pattern and to keep together  command args and command
logic (not mean in one bowl of soup, but like a one logical chunk, for
example like it done in 'Click' with commands decorators, or in command
classes with argparse, for example, guinicorn cli -
https://github.com/benoitc/gunicorn/blob/master/gunicorn/config.py#L548
when you see in one place - command args and command logic (and I don't
mean what need to move config and cli in one, how it's done about gunicorn)

- to get a more testable code and get possible to cover with tests -
getting default values from config, if a cli not provided, correct work in
cases then one option depend on second, check what messages and errors
shows correctly to a user, test correct generating final command and etc.

today most changes in cli merged without tests because in many cases
impossible to write unittests without refactoring existed code.

Also, we will get more possibilities to do a changes in a cli without
afraid to break anything.

So, I want to know your opinion in whole about refactoring cli.py  and
opinions about should we stay with Argparse or should we move to click.

Main idea:
if all will agree about refactoring in whole: I want to get opinions and
comments and prepare some kind of POC on one or two commands to open PR and
start a more substantive discussion. I will be glad to prepare POC, but I
need your thoughts on this scope. I also opened a task, so you can answer
there you want
https://issues.apache.org/jira/projects/AIRFLOW/issues/AIRFLOW-3358.
And thanks all!


-- 
_________

Iuliia