zhongjiajie commented on a change in pull request #7148: [AIRFLOW-6472] Correct
short and long option in cli
URL: https://github.com/apache/airflow/pull/7148#discussion_r385817326
##########
File path: airflow/models/taskinstance.py
##########
@@ -335,30 +335,46 @@ def generate_command(dag_id,
:type local: bool
:param pickle_id: If the DAG was serialized to the DB, the ID
associated with the pickled DAG
- :type pickle_id: unicode
+ :type pickle_id: str
:param file_path: path to the file containing the DAG definition
+ :type file_path: str
:param raw: raw mode (needs more details)
+ :type raw: bool
:param job_id: job ID (needs more details)
+ :type job_id: str
:param pool: the Airflow pool that the task should run in
- :type pool: unicode
+ :type pool: str
:param cfg_path: the Path to the configuration file
:type cfg_path: str
:return: shell command that can be used to run the task instance
+ :rtype: list[str]
"""
iso = execution_date.isoformat()
- cmd = ["airflow", "tasks", "run", str(dag_id), str(task_id), str(iso)]
- cmd.extend(["--mark-success"]) if mark_success else None
- cmd.extend(["--pickle", str(pickle_id)]) if pickle_id else None
- cmd.extend(["--job-id", str(job_id)]) if job_id else None
- cmd.extend(["--ignore-all-dependencies"]) if ignore_all_deps else None
- cmd.extend(["--ignore-dependencies"]) if ignore_task_deps else None
- cmd.extend(["--ignore-depends-on-past"]) if ignore_depends_on_past
else None
- cmd.extend(["--force"]) if ignore_ti_state else None
- cmd.extend(["--local"]) if local else None
- cmd.extend(["--pool", pool]) if pool else None
- cmd.extend(["--raw"]) if raw else None
- cmd.extend(["--subdir", file_path]) if file_path else None
- cmd.extend(["--cfg-path", cfg_path]) if cfg_path else None
+ cmd = ["airflow", "tasks", "run", dag_id, task_id, iso]
+ if mark_success:
+ cmd.extend(["--mark-success"])
+ if pickle_id:
+ cmd.extend(["--pickle", pickle_id])
+ if job_id:
+ cmd.extend(["--job-id", job_id])
+ if ignore_all_deps:
+ cmd.extend(["--ignore-all-dependencies"])
+ if ignore_task_deps:
+ cmd.extend(["--ignore-dependencies"])
+ if ignore_depends_on_past:
+ cmd.extend(["--ignore-depends-on-past"])
+ if ignore_ti_state:
+ cmd.extend(["--force"])
+ if local:
+ cmd.extend(["--local"])
+ if pool:
+ cmd.extend(["--pool", pool])
+ if raw:
+ cmd.extend(["--raw"])
+ if file_path:
+ cmd.extend(["--subdir", file_path])
+ if cfg_path:
+ cmd.extend(["--cfg-path", cfg_path])
Review comment:
I change the code, add typing hint and unit test for this function, WDYT
@feluelle
----------------------------------------------------------------
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