Skip to content

airflowctl: add tasks states-for-dag-run command (closes #66175)#66385

Closed
noahwons wants to merge 2 commits into
apache:mainfrom
noahwons:feature/airflowctl-tasks-states-for-dag-run
Closed

airflowctl: add tasks states-for-dag-run command (closes #66175)#66385
noahwons wants to merge 2 commits into
apache:mainfrom
noahwons:feature/airflowctl-tasks-states-for-dag-run

Conversation

@noahwons
Copy link
Copy Markdown

@noahwons noahwons commented May 5, 2026

Title

airflowctl: add tasks states-for-dag-run command (closes #66175)

Body

Closes #66175.

Builds on top of #66174 #66384 (PR for issue #66174tasks state).

What this PR does

Adds the airflowctl tasks states-for-dag-run subcommand. Given a DAG ID and a DAG run ID, prints a table of all task instances in that run, with their current state, start/end timestamps, and (where applicable) map index. Replicates the legacy airflow tasks states-for-dag-run CLI behavior over the REST API.

Implementation summary

  • New list_states_for_dag_run method on the TasksOperations class added in #______, wrapping GET /dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances. Uses the existing BaseOperations.execute_list helper for automatic pagination.
  • New states_for_dag_run command function in airflow-ctl/src/airflowctl/ctl/commands/tasks_command.py.
  • New ActionCommand registered in the existing TASKS_COMMANDS tuple in cli_config.py with name="states-for-dag-run".
  • Test in test_tasks_command.py exercising the happy path with a mocked REST response.
  • Newsfragment in airflow-ctl/newsfragments/.

Testing

  • pytest airflow-ctl/tests/airflow_ctl/ctl/commands/test_tasks_command.py::TestTasksCommands::test_tasks_states_for_dag_run -v — passes.
  • Manually verified against a local Breeze-started Airflow with a DAG run that had 3 task instances:
    $ airflowctl tasks states-for-dag-run my_dag manual__2025-01-01T00:00:00+00:00
    [
      {"dag_id": "my_dag", "task_id": "extract", "state": "success", ...},
      {"dag_id": "my_dag", "task_id": "transform", "state": "success", ...},
      {"dag_id": "my_dag", "task_id": "load", "state": "success", ...}
    ]
    

AI-assistance disclosure

Per the project's contribution policy: this PR was developed with AI assistance for code drafting and analysis. All code has been reviewed, manually tested by the contributor, and the contributor can explain and defend the changes during review.

noahwons added 2 commits May 4, 2026 23:36
Signed-off-by: noahwons <noahwons@gmail.com>
Signed-off-by: noahwons <noahwons@gmail.com>
@parkhojeong
Copy link
Copy Markdown
Contributor

static check failed. you can use prek

@potiuk
Copy link
Copy Markdown
Member

potiuk commented May 18, 2026

@noahwons A few things need addressing before review — see our Pull Request quality criteria.

Issues found:

  • Pre-commit / static checks: CI image checks / Static checks is failing. Run prek run --from-ref main --stage pre-commit locally and fix anything that flags. See the static-checks docs.

What to do next:

  • Push a fix for the static-check failure.

No rush — take your time. We appreciate your contribution and are happy to wait for updates. If you have questions, feel free to ask on the Airflow Slack.


Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you.

@noahwons noahwons closed this May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AIP-94] airflowctl tasks: add states-for-dag-run command

3 participants