Repository navigation
CLI: Add --limit flag to airflow dags list-runs - #71729
Conversation
8fb6da0 to
ee3e3c5
Compare
|
Thanks! Since this adds a user-facing |
ee3e3c5 to
f1f556d
Compare
f1f556d to
2e2bc0f
Compare
|
Awesome!! |
potiuk
left a comment
There was a problem hiding this comment.
Thanks — small, well-scoped addition: argparse-level validation via positive_int(allow_zero=False) and slicing after the run_after DESC sort gives exactly the "N most recent runs" semantics. Approving.
A few non-blocking notes:
--limitcaps the output, butDagRun.findstill loads every matching run, so the database/memory cost on a busy Dag is unchanged. Fine for a CLI; just worth knowing if someone later wants to push the limit into the query.test_cli_list_dag_runs_limitchecks the returned rows are sorted, which a wrong-but-sorted subset would also satisfy. Asserting the run ids (e.g.--limit 1→cli_limit_test_2) would pin the "most recent" part.- The newsfragment isn't required —
AGENTS.mdreservesairflow-core/newsfragments/for major or breaking changes — but it does no harm; keep or drop as you prefer.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.More on how Apache Airflow handles maintainer review:
contributing-docs/05_pull_requests.rst.
Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting
airflow dags list-jobs already accepts --limit but the neighbouring list-runs command does not, so operators on busy DAGs have to pipe through head or use date filters to shorten output. Mirroring the existing flag closes that asymmetry and makes the two commands predictable together.
2e2bc0f to
07a8de9
Compare
Summary
airflow dags list-jobsaccepts--limit, but the siblingairflow dags list-runscommand does not — on busy DAGs the command dumps every run since the start of time (subject to date filters). This PR closes that asymmetry with a small, additive flag.Details
ARG_DR_LIMITtyped aspositive_int(allow_zero=False)— argparse rejects0, negative numbers, and non-numeric input up-front.dag_list_dag_runsafter the existingrun_afterDESC sort, so--limit Nreliably returns the N most recent runs regardless of insertion order inDagRun.find.Test plan
ruff formatandruff checkclean.--limit 3parses toint(3);--limit 0,--limit -1,--limit abcall rejected by argparse;--limitshows indags list-runs --help.uv run --project airflow-core pytest airflow-core/tests/unit/cli/commands/test_dag_command.py::TestCliDags::test_cli_list_dag_runs airflow-core/tests/unit/cli/commands/test_dag_command.py::TestCliDags::test_cli_list_dag_runs_limit airflow-core/tests/unit/cli/commands/test_dag_command.py::TestCliDags::test_cli_list_dag_runs_limit_rejects_invalid -xvsprek run --from-ref main --stage pre-commitWas generative AI tooling used to co-author this PR?