Add tasks state command to airflowctl#66202
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
|
| ti = api_client.task_instances.get( | ||
| dag_id=args.dag_id, | ||
| dag_run_id=args.dag_run_id, | ||
| task_id=args.task_id, | ||
| ) |
There was a problem hiding this comment.
I think we should add a try-except block to catch errors.
There was a problem hiding this comment.
@henry3260 Thanks for reviewing my PR!
I believe this is already handled by the safe_call_command function. It captures server error messages and prints them out as shown in the attached image.
fc66067 to
2157b46
Compare
No problem! I've just added the tests to cover this feature. Let me know if they look good to you. |
2157b46 to
15cf0f0
Compare
parkhojeong
left a comment
There was a problem hiding this comment.
i checked term usage :)
@parkhojeong Appreciate that! Thanks for checking. |
4b2f9a4 to
be7243b
Compare
There was a problem hiding this comment.
This appears to be an unrelated change. You might need a rebase (:
There was a problem hiding this comment.
Thanks. Just rebased it and cleaned up the commits.
be7243b to
30689b2
Compare
30689b2 to
86529ac
Compare
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
86529ac to
f1e9062
Compare
| class TaskInstancesOperations(BaseOperations): | ||
| """Task instance operations.""" | ||
|
|
||
| def get(self, dag_id: str, dag_run_id: str, task_id: str) -> TaskInstanceResponse | ServerResponseError: |
There was a problem hiding this comment.
I think mapped task instances are currently missing from this implementation.
A task instance is not always identified only by (dag_id, dag_run_id, task_id). For mapped tasks, map_index is also part of the identity, and the public API exposes a separate mapped task instance endpoint for that case.
As implemented, airflowctl tasks state can only query non-mapped task instances, so users have no way to get the state of a mapped task instance through this command. This also means it does not match legacy airflow tasks state, which supports --map-index.
Was generative AI tooling used to co-author this PR?
{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.