Skip to content

Add airflowctl tasks clear command#66926

Open
Bishesh-Shahi wants to merge 4 commits into
apache:mainfrom
Bishesh-Shahi:feature/airflowctl-tasks-clear
Open

Add airflowctl tasks clear command#66926
Bishesh-Shahi wants to merge 4 commits into
apache:mainfrom
Bishesh-Shahi:feature/airflowctl-tasks-clear

Conversation

@Bishesh-Shahi
Copy link
Copy Markdown

@Bishesh-Shahi Bishesh-Shahi commented May 14, 2026

Closes #66176

This PR introduces the airflowctl tasks clear command to the new Airflow CLI interface, satisfying the requirements of AIP-94.

Changes:

  • Added TasksOperations to airflow-ctl/src/airflowctl/api/operations.py that maps clear to the core API's POST /api/v2/dags/{dag_id}/clearTaskInstances endpoint.
  • Registered the tasks property in the Client to automatically generate the command and its arguments via cli_config.py.
  • Added an integration test for tasks clear example_bash_operator in test_airflowctl_commands.py.

@boring-cyborg
Copy link
Copy Markdown

boring-cyborg Bot commented May 14, 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

@vincbeck
Copy link
Copy Markdown
Contributor

Text is malformed, can you fix that?

@Bishesh-Shahi Bishesh-Shahi changed the title Add \irflowctl tasks clear\ command Add airflowctl tasks clear command May 14, 2026
@Bishesh-Shahi
Copy link
Copy Markdown
Author

Thanks for pointing that out @vincbeck! It was a formatting issue caused by my terminal escaping the markdown backticks during submission. I've just updated the PR title and description, and it should be properly formatted now.

Copy link
Copy Markdown
Contributor

@bugraoz93 bugraoz93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add unit tests and integrations tests under airflow-ctl-test/?

@Bishesh-Shahi
Copy link
Copy Markdown
Author

Bishesh-Shahi commented May 14, 2026

Thanks for the review @bugraoz93! I had actually already included the integration test for tasks clear inside airflow-ctl-tests/tests/airflowctl_tests/test_airflowctl_commands.py in the initial commit. However, I have now also added the requested unit test for TasksOperations under airflow-ctl/tests/airflow_ctl/api/test_operations.py. Let me know if there's anything else needed!

This commit introduces the TasksOperations class to airflowctl/api/operations.py and wires it up to the Client, which allows the dynamic generation of the �irflowctl tasks clear CLI command. It also includes integration tests.

Closes apache#66176
@Bishesh-Shahi Bishesh-Shahi force-pushed the feature/airflowctl-tasks-clear branch from a992af5 to bcad3cc Compare May 19, 2026 19:52
Copy link
Copy Markdown
Contributor

@bugraoz93 bugraoz93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks looks clean, will trigger full test for integration run, when green we can merge. Will be included in the release

@bugraoz93 bugraoz93 added the full tests needed We need to run full set of tests for this PR to merge label May 19, 2026
@bugraoz93 bugraoz93 closed this May 19, 2026
@bugraoz93 bugraoz93 reopened this May 19, 2026
Copy link
Copy Markdown
Contributor

@bugraoz93 bugraoz93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a second looks this should trigger help image generation and some more.
Can you please check the scripts generationg the images for the tasks and new command

@bugraoz93
Copy link
Copy Markdown
Contributor

@Bishesh-Shahi Bishesh-Shahi requested a review from jscheffl as a code owner May 19, 2026 23:05
@Bishesh-Shahi
Copy link
Copy Markdown
Author

Could you please also add def here https://github.com/apache/airflow/blob/main/airflow-ctl/src/airflowctl/ctl/help_texts.yaml?

Hi @bugraoz93,

Thank you for the catch! I have updated the PR to fully support help text definitions and help image generation for the new tasks command and clear subcommand:

  1. Added the tasks: clear: "Clear task instances" definition to airflow-ctl/src/airflowctl/ctl/help_texts.yaml.
  2. Updated the image generation script (scripts/in_container/run_capture_airflowctl_help.py) by adding "tasks" to COMMANDS and "tasks clear" to SUBCOMMANDS.
  3. Generated and updated the MD5 hashes in command_hashes.txt.
  4. Generated the preview SVGs output_tasks.svg and output_tasks_clear.svg under standard terminal configurations.
  5. Verified that both check_airflowctl_help_texts.py and check_airflowctl_command_coverage.py pre-commit checks pass successfully.

Please let me know if there's anything else that needs addressing before review!

@Bishesh-Shahi Bishesh-Shahi requested a review from bugraoz93 May 20, 2026 20:10
tasks:8ca7306be97d1c8788dbfbe4b0f8bf61
auth login:9fe2bb1dd5c602beea2eefb33a2b20a8
tasks clear:151c473a0b6653553149513b46e58072

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be autogenerated, seems something went wrong

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have two entry should be one

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching that @bugraoz93! You're right on both points:I had mistakenly added "tasks clear" to the SUBCOMMANDS list in run_capture_airflowctl_help.py, which caused the file to be generated with two entries (tasks and tasks clear) instead of just one.I've reverted that- only "tasks" is now registered under COMMANDS (matching the pattern used by all other top-level command groups). The command_hashes.txt now has a single correct entry for tasks, and output_tasks_clear.svg has been removed.
The file has been regenerated correctly and both prek checks pass. Sorry for the noise!

@Bishesh-Shahi Bishesh-Shahi force-pushed the feature/airflowctl-tasks-clear branch from 70f27f3 to df8ebfd Compare May 20, 2026 20:30
@Bishesh-Shahi Bishesh-Shahi force-pushed the feature/airflowctl-tasks-clear branch from df8ebfd to 3be6196 Compare May 20, 2026 20:33
@Bishesh-Shahi Bishesh-Shahi requested a review from bugraoz93 May 20, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:airflow-ctl backport-to-airflow-ctl/v0-1-test full tests needed We need to run full set of tests for this PR to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AIP-94] airflowctl tasks: add clear command

3 participants