You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by je...@apache.org on 2022/09/14 17:03:51 UTC

[airflow] branch main updated: Require dag_id arg for dags list-runs (#26357)

This is an automated email from the ASF dual-hosted git repository.

jedcunningham pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new f6c579c1c0 Require dag_id arg for dags list-runs (#26357)
f6c579c1c0 is described below

commit f6c579c1c0efb8cdd2eaf905909cda7bc7314f88
Author: Jed Cunningham <66...@users.noreply.github.com>
AuthorDate: Wed Sep 14 10:03:21 2022 -0700

    Require dag_id arg for dags list-runs (#26357)
    
    While it would ideal to transition to a positional arg like was
    attempted in #25978, this unfortunately does result in a breaking change
    so we cannot do it now.
    
    By instead marking the existing arg as required, we maintain backcompat
    while also providing a helpful error message to the user if they forget
    it.
    
    This reverts commit ed6ea72f181a1d381cc1ff6c801f10cc0bc0d830.
---
 airflow/cli/cli_parser.py              | 5 ++++-
 tests/cli/commands/test_dag_command.py | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/airflow/cli/cli_parser.py b/airflow/cli/cli_parser.py
index 6581cfe632..c26b44e178 100644
--- a/airflow/cli/cli_parser.py
+++ b/airflow/cli/cli_parser.py
@@ -263,6 +263,9 @@ ARG_REVISION_RANGE = Arg(
 )
 
 # list_dag_runs
+ARG_DAG_ID_REQ_FLAG = Arg(
+    ("-d", "--dag-id"), required=True, help="The id of the dag"
+)  # TODO: convert this to a positional arg in Airflow 3
 ARG_NO_BACKFILL = Arg(
     ("--no-backfill",), help="filter all the backfill dagruns given the dag id", action="store_true"
 )
@@ -1008,7 +1011,7 @@ DAGS_COMMANDS = (
         ),
         func=lazy_load_command('airflow.cli.commands.dag_command.dag_list_dag_runs'),
         args=(
-            ARG_DAG_ID,
+            ARG_DAG_ID_REQ_FLAG,
             ARG_NO_BACKFILL,
             ARG_STATE,
             ARG_OUTPUT,
diff --git a/tests/cli/commands/test_dag_command.py b/tests/cli/commands/test_dag_command.py
index bec69fb60a..99e27fb8c2 100644
--- a/tests/cli/commands/test_dag_command.py
+++ b/tests/cli/commands/test_dag_command.py
@@ -499,12 +499,13 @@ class TestCliDags(unittest.TestCase):
             [
                 'dags',
                 'list-runs',
+                '--dag-id',
+                'example_bash_operator',
                 '--no-backfill',
                 '--start-date',
                 DEFAULT_DATE.isoformat(),
                 '--end-date',
                 timezone.make_aware(datetime.max).isoformat(),
-                'example_bash_operator',
             ]
         )
         dag_command.dag_list_dag_runs(args)