You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/07/05 07:59:26 UTC

[GitHub] [airflow] ashb commented on a diff in pull request #23870: DAG regex flag in backfill command

ashb commented on code in PR #23870:
URL: https://github.com/apache/airflow/pull/23870#discussion_r913494733


##########
airflow/cli/commands/dag_command.py:
##########
@@ -66,64 +69,82 @@ def dag_backfill(args, dag=None):
     if not args.start_date and not args.end_date:
         raise AirflowException("Provide a start_date and/or end_date")
 
-    dag = dag or get_dag(args.subdir, args.dag_id)
+    if not dag:
+        dags = get_dags(args.subdir, dag_id=args.dag_id, use_regex=args.treat_dag_as_regex)
+    else:
+        dags = dag if type(dag) == list else [dag]
+
+    dags.sort(key=lambda d: d.dag_id)
+
+    dag_id_list = "\n".join(str(dag.dag_id) for dag in dags)
+    question = (
+        "You are about to backfill these {count} DAGs:\n{dag_id_list}\n\nAre you sure? [y/n]"
+    ).format(count=len(dags), dag_id_list=dag_id_list)
+    do_it = ask_yesno(question)

Review Comment:
   This is new behaviour and might break some peoples workflows (as I know some people script `airflow backfill` on occasion). I think we should only ask then `treat_dag_as_regex` is set.



##########
airflow/cli/commands/dag_command.py:
##########
@@ -66,64 +69,82 @@ def dag_backfill(args, dag=None):
     if not args.start_date and not args.end_date:
         raise AirflowException("Provide a start_date and/or end_date")
 
-    dag = dag or get_dag(args.subdir, args.dag_id)
+    if not dag:
+        dags = get_dags(args.subdir, dag_id=args.dag_id, use_regex=args.treat_dag_as_regex)
+    else:
+        dags = dag if type(dag) == list else [dag]
+
+    dags.sort(key=lambda d: d.dag_id)
+
+    dag_id_list = "\n".join(str(dag.dag_id) for dag in dags)
+    question = (
+        "You are about to backfill these {count} DAGs:\n{dag_id_list}\n\nAre you sure? [y/n]"
+    ).format(count=len(dags), dag_id_list=dag_id_list)
+    do_it = ask_yesno(question)

Review Comment:
   @potiuk That said, why do we need this confirmation/question at all when the we already have a `--dry-run` flag? 



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org