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

@kyupark kyupark commented May 13, 2026

Copy link
Copy Markdown
Contributor

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


Important

🛠️ Maintainer triage note for @kyupark · by @potiuk · 2026-07-08 15:51 UTC

Some review feedback from @potiuk is waiting on you (4 unresolved threads):

The ball is in your court — you've been assigned to this PR. Reply or push a fix in each thread, then mark them resolved. See the Pull Request quality criteria.

Automated triage — may be imperfect; a maintainer takes the next look.

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

kyupark commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

Sorry I mixed up. Should be good now

@kyupark

kyupark commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

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

kyupark commented May 16, 2026

Copy link
Copy Markdown
Contributor Author

CI is green now

@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label May 19, 2026

@bugraoz93 bugraoz93 left a comment

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.

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

@bugraoz93 bugraoz93 left a comment

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.

I saw what you separated over routes, but we need Airflow core CLI parity rather. So we should combine them under tasks only and then name them accordingly. Same as the Asset get and get_alias, we can do get() and for Tasks route we can name it differently, as they are per dag. Like g

"""Operations related to tasks."""
return TasksOperations(self)

@lru_cache() # type: ignore[prop-decorator]

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 needs to be gone because we removed other parts and it should stay as tasks

@potiuk

potiuk commented Jun 25, 2026

Copy link
Copy Markdown
Member

@kyupark — I've removed the ready for maintainer review label because the next step here is yours: there are 2 unresolved review thread(s) awaiting your reply. It'll go back into the maintainer queue automatically once you've addressed them — no need to re-add the label by hand. There's no rush.

Automated triage note drafted by an AI-assisted tool — may get things wrong; a real Apache Airflow maintainer takes the next look once they're resolved. (why automated)


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

@potiuk potiuk removed the ready for maintainer review Set after triaging when all criteria pass. label Jun 25, 2026
@potiuk

potiuk commented Jul 20, 2026

Copy link
Copy Markdown
Member

@kyupark — There are 2 unresolved review thread(s) on this PR from @bugraoz93. Could you either push a fix or reply in each thread explaining why the feedback doesn't apply? Once you believe the feedback is addressed, mark the thread as resolved so the reviewer isn't re-pinged needlessly. Thanks!


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.

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 clear command

5 participants