Skip to content

Add tasks clear command to airflowctl#66852

Open
kyupark wants to merge 3 commits into
apache:mainfrom
kyupark:add-tasks-clear-66176
Open

Add tasks clear command to airflowctl#66852
kyupark wants to merge 3 commits into
apache:mainfrom
kyupark:add-tasks-clear-66176

Conversation

@kyupark
Copy link
Copy Markdown
Contributor

@kyupark kyupark commented May 13, 2026

Add a tasks clear command to airflowctl, allowing users to clear task instances via the CLI.

Supports --dag-id, --task-id, --start-date, and --end-date flags. Uses the POST /api/v2/dags/{dag_id}/clearTaskInstances endpoint.

closes: #66176


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.7)

Generated-by: Claude Code (Opus 4.7) following the guidelines

mail_folder: str = "INBOX",
mail_filter: str = "All",
not_found_mode: str = "raise",
overwrite: bool = True,
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.

related to this PR - #66850
Could you please remove these unrelated chnages

const utc = parsed.toISOString();
setDisplayDate(local);
onChange?.({ ...event, target: { ...event.target, value: utc } } as unknown as ChangeEvent<HTMLInputElement>);
};
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.

@kyupark some unrelated chnages
It seems like these are related to #66851
Would you please check ?

Add TasksOperations and TaskInstancesOperations to the API layer,
a tasks clear command to airflowctl, and register the tasks command
group in the CLI.

The clear command supports optional --start-date and --end-date flags
in ISO format.

Closes apache#66176
@kyupark kyupark force-pushed the add-tasks-clear-66176 branch from e6a0496 to ba07330 Compare May 13, 2026 16:12
@kyupark
Copy link
Copy Markdown
Contributor Author

kyupark commented May 13, 2026

Sorry I mixed up. Should be good now

@kyupark
Copy link
Copy Markdown
Contributor Author

kyupark commented May 13, 2026

Fixed the CI/static-check failures from the airflowctl tasks clear changes.

What changed:

  • Removed the return value from the CLI command handler, fixing the mypy No return value expected error.
  • Updated the command tests to assert console output instead of relying on a returned response.
  • Excluded the newly added operation classes from the generic auto-generated airflowctl command checks, so this PR does not unintentionally require generated commands such as tasks get/list and taskinstances ....

Verification:

  • uv run --project airflow-ctl pytest airflow-ctl/tests/airflow_ctl/ctl/commands/test_task_command.py -q: 3 passed
  • prek run check-airflowctl-command-coverage --all-files: passed
  • prek run check-airflowctl-help-texts --all-files: passed
  • prek run mypy-airflow-ctl --all-files: passed
  • codex review --commit HEAD: 0 review comments

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

@parkhojeong
Copy link
Copy Markdown
Contributor

CI Generate SVG from Airflow CTL Commands failed. please check it

Include `tasks` in the capture snapshot list so CI help-image checks stay in sync after adding `tasks clear`.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kyupark
Copy link
Copy Markdown
Contributor Author

kyupark commented May 16, 2026

CI is green now

@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label 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.

Thanks! Good to add the image help script but we need to move the logic to operations.py as the cli command will be autogenerated we need to add help text to yaml definition
https://github.com/apache/airflow/blob/main/airflow-ctl/src/airflowctl/ctl/help_texts.yaml


@provide_api_client(kind=ClientKind.CLI)
def clear(args, api_client=NEW_API_CLIENT) -> None:
"""Clear task instances for a Dag."""
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 in operations.py since we can call with single endpoint and we don't need to maintain this much LoC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AIP-94] airflowctl tasks: add clear command

5 participants