Support --map-index in airflowctl tasks state#68776
Open
IamJasonBian wants to merge 7 commits into
Open
Conversation
Introduce `airflowctl tasks state` to retrieve the state of a task
instance by calling GET /api/v2/dags/{dag_id}/dagRuns/{run_id}/
taskInstances/{task_id}. Also add TaskInstancesOperations, help text,
and an integration test for the auto-generated taskinstances get command.
# Conflicts:
# airflow-ctl-tests/tests/airflowctl_tests/test_airflowctl_commands.py
Allow `airflowctl tasks state` to query mapped task instances, matching the legacy `airflow tasks state --map-index` behaviour. When the flag is non-negative the mapped task instance endpoint is called; otherwise the existing unmapped endpoint is used. The `taskinstances get` auto-generated command also gains optional mapped-instance support via the same `map_index` parameter on `TaskInstancesOperations.get`.
The integration test invoked `taskinstances get` with `--dag-id`/`--dag-run-id`/ `--task-id` flags, but that auto-generated command takes positional arguments, so argparse exited with code 2 and the test failed. The flag syntax belongs to the new `tasks state` command, which had no integration coverage at all. Point the entry at `tasks state` (flags) to cover the new command, and add a correctly-formed `taskinstances get` entry using positional args so both commands are exercised.
Contributor
There was a problem hiding this comment.
Do you think it's also worth adding a test to the test_operations.py file for the get command? The tests you added only seem to cover tasks state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a
tasks statecommand toairflowctland supports--map-indexso thestate of a specific mapped task instance can be retrieved through the CLI:
Also fixes the airflowctl integration test that exercised this area: it had
invoked the auto-generated
taskinstances getcommand with--dag-id/--dag-run-id/--task-idflags, which that command does not accept (it takespositional args), causing argparse to exit 2. The entry now uses
tasks state(flags) to cover the new command, plus a correctly-formed positional
taskinstances getentry so both commands are exercised.Testing
Set up localhost:8080
Ran below after toggling in UI
Reran CI locally
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.8) following the guidelines