Support --map-index in airflowctl tasks state#66509
Conversation
|
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
|
|
@IamJasonBian Thanks! I’ve merged your suggested changes into my PR. The branch is now updated with the additional commits. (d76a2fc) |
|
@IamJasonBian A few things need addressing before review — see our Pull Request quality criteria.
No rush. 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. Drafted-by: Claude Code (Opus 4.7); reviewed by @potiuk before posting |
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`.
3b15121 to
9f9eb16
Compare
|
@potiuk thanks! - added to docs/spelling_wordlist.txt and rebased |
Stacked on top of #66202 — opening as a draft so the follow-up is visible while #66202 is still in review.
Addresses @parkhojeong's CHANGES_REQUESTED feedback on #66202: the new
airflowctl tasks statecommand currently can't query a mapped task instance, so it doesn't match legacyairflow tasks state --map-index. The Airflow REST API exposes a separate path-parameter endpoint for mapped instances:GET /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}GET /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}Hitting the unmapped endpoint for a mapped TI returns a 404 with the message "Task instance is mapped, add the map_index value to the URL", so today the command just hard-fails on any mapped task.
Changes (top commit only —
7156ab6)TaskInstancesOperations.getnow accepts an optionalmap_indexand routes to the mapped endpoint when it's non-negative. Sentinel uses the existingint = None # type: ignorepattern fromXComOperationsso the auto-generatedtaskinstances getcommand continues to work when the flag is omitted.--map-indexflag onairflowctl tasks state(default-1, matching legacyairflow tasks statesemantics).map_index ∈ {0, 1, 7}); existing unmapped tests untouched.taskinstances getcommand also gains optional--map-indexsupport transparently.Stacking note
The bottom two commits in this branch (
cfdb6617,f1e90629) belong to @hyungryuk from #66202 — they're only here because #66202 hasn't merged yet. Once #66202 lands, this PR will rebase to the single7156ab6commit (52 +/3 - across 4 files) and come out of draft.If @hyungryuk would prefer to fold the map-index support directly into #66202 instead of landing it as a follow-up, I'm happy to close this and push the diff there as a suggested change.
related: #66174
follows: #66202
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.7) following the guidelines