Skip to content

Feat/task instance cli support#63889

Open
Suraj-kumar00 wants to merge 4 commits intoapache:mainfrom
Suraj-kumar00:feat/task-instance-cli-support
Open

Feat/task instance cli support#63889
Suraj-kumar00 wants to merge 4 commits intoapache:mainfrom
Suraj-kumar00:feat/task-instance-cli-support

Conversation

@Suraj-kumar00
Copy link

@Suraj-kumar00 Suraj-kumar00 commented Mar 18, 2026

Adds Task Instance management support to the airflowctl CLI, enabling users to get, list, clear, and update task instances directly from the terminal.

Closes: #61547

Changes

airflowctl/api/operations.py

  • Introduced TaskInstanceOperations class with the following methods:

    • get
    • list
    • clear
    • update
  • Reuses existing auto-generated Pydantic models for request and response validation.

  • Implements intelligent unwrapping of Airflow’s nested TaskInstanceCollectionResponse for get and update operations to prevent Pydantic validation errors.

airflowctl/api/client.py

  • Added task_instances property to the Client, enabling proper wiring of auto-generated CLI commands.

airflowctl/ctl/cli_config.py

  • Added "clear" to output_command_list for correct CLI output handling.
  • Improved API field parsing to automatically convert comma-separated CLI inputs into properly formatted lists when required by Pydantic models
    (e.g., --task-id task_1,task_2["task_1", "task_2"]).

tests/airflow_ctl/api/test_operations.py

  • Added a comprehensive TestTaskInstanceOperations test suite with 6 focused unit tests.

  • Covers:

    • get
    • list
    • clear (default and with options)
    • update (state updates and note additions)
  • Follows the existing XCom testing pattern from Add XCom CLI commands to airflowctl #61021.

airflow-ctl-tests/tests/airflowctl_tests/test_airflowctl_commands.py

  • Added end-to-end integration tests mapping all 4 taskinstance commands to their expected execution hashes.

New CLI Commands

airflowctl taskinstance list --dag-id <dag_id> --dag-run-id <run_id>
airflowctl taskinstance get --dag-id <dag_id> --dag-run-id <run_id> --task-id <task_id>
airflowctl taskinstance clear --dag-id <dag_id> [--dry-run] [--only-failed] [--task-ids ...]
airflowctl taskinstance update --dag-id <dag_id> --dag-run-id <run_id> --task-id <task_id> [--new-state <state>] [--note <note>]
Screenshot 2026-03-18 at 9 32 30 PM
Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

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.

airflowctl: Add support to manage Task Instances

1 participant