Skip to content

airflowctl: add tasks state command (closes #66174)#66384

Closed
noahwons wants to merge 1 commit into
apache:mainfrom
noahwons:feature/airflowctl-tasks-state
Closed

airflowctl: add tasks state command (closes #66174)#66384
noahwons wants to merge 1 commit into
apache:mainfrom
noahwons:feature/airflowctl-tasks-state

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 #______ (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.

Signed-off-by: noahwons <noahwons@gmail.com>
@boring-cyborg
Copy link
Copy Markdown

boring-cyborg Bot commented May 5, 2026

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@parkhojeong
Copy link
Copy Markdown
Contributor

ci looks failed. https://github.com/apache/airflow/actions/runs/25358208398/job/74471164072?pr=66384
you can use prek in local

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

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

  • Pre-commit / static checks — Failing: CI image checks / Static checks. See docs.

Note: Your branch is 361 commits behind main. Please rebase and push again to get up-to-date CI results.

No rush.


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.


Drafted-by: Claude Code (Opus 4.7); reviewed by @potiuk before posting

@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