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 12:45:20 UTC

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

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


##########
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?
   
   We don't `need` it - we can remove it. It was overcautious from my side a bit.
   
   > If we are just doing this sequentially (rather than all dags in a single BackfillJob) I'm not even all that sure we need this feature. Isn't this very very similar to a loop in bash:
   
   I think it's still useful. I am also in the spree of replacing everything we "NEED" to do to be done in Python rather having to write bash scripts, If the user would want to write a bash script to run something with airflow CLI, IMHO this is a sign that we can improve the CLI. 
   
   Especially that if we will (soon I hope?) have rather good (for now for development but it should be good enough for CLI management)  native Windows support, that means that if we want to advise the user to run backfill for multiple dags, we would have to do "run a bash or Powershell command similar to this or that" or smth. 
   
   I think having a good native support on Windows is important for the 1) users from Vikram's email at the devlist https://lists.apache.org/thread/smfpovyh1hfych9wmbsnvwt397hh7g11. 
   
   Having such capabilities in cross-platform python airflow CLI is rather valuable I think.
   



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