noahwons opened a new pull request, #66384:
URL: https://github.com/apache/airflow/pull/66384
# Title
airflowctl: add `tasks states-for-dag-run` command (closes #66175)
# Body
Closes #66175.
Builds on top of #______ (PR for issue #66174 — `tasks 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.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]