You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Suraj-kumar00 (via GitHub)" <gi...@apache.org> on 2026/02/15 12:39:13 UTC

[PR] feat(airflowctl): add task instance management support [airflow]

Suraj-kumar00 opened a new pull request, #61946:
URL: https://github.com/apache/airflow/pull/61946

   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
   
   **airflow-ctl/src/airflowctl/api/operations.py**
   - Added TaskInstanceOperations class with get, list, clear, and update methods
   - Uses existing auto-generated Pydantic models for request/response validation
   
   **airflow-ctl/src/airflowctl/api/client.py**
   - Added task_instances property to Client, enabling auto-generated CLI commands
   
   **airflow-ctl-tests/tests/airflowctl_tests/test_airflowctl_commands.py**
   - Added taskinstance list and taskinstance get integration tests
   
   ### New CLI Commands
   
   ```bash
   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> [options]
   airflowctl taskinstance update --dag-id <dag_id> --dag-run-id <run_id> --task-id <task_id> [options]
   ```
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Gemini following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   ---
   
   * Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#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](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(airflowctl): add task instance management support [airflow]

Posted by "Suraj-kumar00 (via GitHub)" <gi...@apache.org>.
Suraj-kumar00 commented on PR #61946:
URL: https://github.com/apache/airflow/pull/61946#issuecomment-3909567166

   
   Thanks for the detailed review @dheerajturaga! I've addressed all the feedback:
   
   1. **Unit tests** — Added comprehensive `TestTaskInstanceOperations` test suite in `test_operations.py` with 6 tests covering all operations (`get`, `list`, `clear`, `clear_with_options`, `update`, `update_with_note`), following the XCom tests pattern from #61021.
   
   2. **Integration tests** — Added `taskinstance clear` and `taskinstance update` integration tests in `test_airflowctl_commands.py`.
   
   3. **`clear` output command** — Added `"clear"` to `output_command_list` in `cli_config.py`.
   
   4. **Static code checks** — Ran `ruff` locally; all checks passed.
   
   All 6 unit tests pass locally. Let me know if there's anything else!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(airflowctl): add task instance management support [airflow]

Posted by "dheerajturaga (via GitHub)" <gi...@apache.org>.
dheerajturaga commented on PR #61946:
URL: https://github.com/apache/airflow/pull/61946#issuecomment-3910325391

   > 
   > 
   > Thanks for the detailed review @dheerajturaga! I've addressed all the feedback:
   > 
   > 
   > 
   > 1. **Unit tests** — Added comprehensive `TestTaskInstanceOperations` test suite in `test_operations.py` with 6 tests covering all operations (`get`, `list`, `clear`, `clear_with_options`, `update`, `update_with_note`), following the XCom tests pattern from #61021.
   > 
   > 
   > 
   > 2. **Integration tests** — Added `taskinstance clear` and `taskinstance update` integration tests in `test_airflowctl_commands.py`.
   > 
   > 
   > 
   > 3. **`clear` output command** — Added `"clear"` to `output_command_list` in `cli_config.py`.
   > 
   > 
   > 
   > 4. **Static code checks** — Ran `ruff` locally; all checks passed.
   > 
   > 
   > 
   > All 6 unit tests pass locally. Let me know if there's anything else!
   > 
   > 
   
   Thanks for adding the tests! 😃
   I see that the static checks are still failing. Just running ruff isn't enough, you would need to run the prek pre commit checks as mentioned in my earlier comment. Please give it a quick read. It should also automatically update the images for the airflowctl docs. 
   
   I also see that the airflowctl checks are failing. Please address them as well 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(airflowctl): add task instance management support [airflow]

Posted by "Suraj-kumar00 (via GitHub)" <gi...@apache.org>.
Suraj-kumar00 commented on PR #61946:
URL: https://github.com/apache/airflow/pull/61946#issuecomment-3904491905

   Hi @shahar1, 
   
   Please review


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(airflowctl): add task instance management support [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #61946:
URL: https://github.com/apache/airflow/pull/61946#issuecomment-4040177966

   @Suraj-kumar00 This PR has been converted to **draft** because it does not yet meet our [Pull Request quality criteria](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-quality-criteria).
   
   **Issues found:**
   - :x: **Other failing CI checks**: Failing: Additional PROD image tests / Airflow CTL integration tests with PROD image. Run `prek run --from-ref main` locally to reproduce. See [static checks docs](https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst).
   
   > **Note:** Your branch is **606 commits behind `main`**. Some check failures may be caused by changes in the base branch rather than by your PR. Please rebase your branch and push again to get up-to-date CI results.
   
   **What to do next:**
   - The comment informs you what you need to do.
   - Fix each issue, then mark the PR as "Ready for review" in the GitHub UI - but only after making sure that all the issues are fixed.
   - Maintainers will then proceed with a normal review.
   
   Converting a PR to draft is **not** a rejection — it is an invitation to bring the PR up to the project's standards so that maintainer review time is spent productively. If you have questions, feel free to ask on the [Airflow Slack](https://s.apache.org/airflow-slack).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(airflowctl): add task instance management support [airflow]

Posted by "Suraj-kumar00 (via GitHub)" <gi...@apache.org>.
Suraj-kumar00 commented on PR #61946:
URL: https://github.com/apache/airflow/pull/61946#issuecomment-3920589586

   Hi @dheerajturaga,
   
   Please review...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(airflowctl): add task instance management support [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #61946:
URL: https://github.com/apache/airflow/pull/61946#issuecomment-3904381953

   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 (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (ruff, mypy and type annotations). Our [prek-hooks]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-prek-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
   - Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(airflowctl): add task instance management support [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk closed pull request #61946: feat(airflowctl): add task instance management support
URL: https://github.com/apache/airflow/pull/61946


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(airflowctl): add task instance management support [airflow]

Posted by "dheerajturaga (via GitHub)" <gi...@apache.org>.
dheerajturaga commented on PR #61946:
URL: https://github.com/apache/airflow/pull/61946#issuecomment-3941800720

   @Suraj-kumar00 please fix the CI checks?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(airflowctl): add task instance management support [airflow]

Posted by "Suraj-kumar00 (via GitHub)" <gi...@apache.org>.
Suraj-kumar00 commented on PR #61946:
URL: https://github.com/apache/airflow/pull/61946#issuecomment-3904787175

   > Thanks for the PR and it looks good! We were going to release new version which delayed a week and some breaking changes needs to be fixes here #61822. Lets hold adding more feature for a couple of days as and decide how to go with schema evolution and we can fit this into new release :)
   
   Sure @bugraoz93, thanks for the update!
   
   Let me know if i can help you with anything from my end.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(airflowctl): add task instance management support [airflow]

Posted by "dheerajturaga (via GitHub)" <gi...@apache.org>.
dheerajturaga commented on code in PR #61946:
URL: https://github.com/apache/airflow/pull/61946#discussion_r2809809626


##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -824,3 +828,54 @@ def delete(
             return key
         except ServerResponseError as e:
             raise e
+
+
+class TaskInstanceOperations(BaseOperations):
+    """Task instance operations."""
+
+    def get(
+        self, dag_id: str, dag_run_id: str, task_id: str
+    ) -> TaskInstanceResponse | ServerResponseError:
+        """Get a task instance."""
+        try:
+            self.response = self.client.get(
+                f"dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}"
+            )
+            return TaskInstanceResponse.model_validate_json(self.response.content)
+        except ServerResponseError as e:
+            raise e
+
+    def list(
+        self, dag_id: str, dag_run_id: str
+    ) -> TaskInstanceCollectionResponse | ServerResponseError:
+        """List task instances."""
+        return super().execute_list(
+            path=f"dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances",
+            data_model=TaskInstanceCollectionResponse,
+        )
+
+    def clear(

Review Comment:
   clear seems to be a new output command. You would need to add it to the command list here
   https://github.com/apache/airflow/blob/7b33e9baf0443e11548fd5a9eb6fe395397993a7/airflow-ctl/src/airflowctl/ctl/cli_config.py#L387
   
   Take a look at the example: #61021



##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -824,3 +828,54 @@ def delete(
             return key
         except ServerResponseError as e:
             raise e
+
+
+class TaskInstanceOperations(BaseOperations):

Review Comment:
   Unit tests for api operations are captured here https://github.com/apache/airflow/blob/7b33e9baf0443e11548fd5a9eb6fe395397993a7/airflow-ctl/tests/airflow_ctl/api/test_operations.py
   
   Would you be able to add a comprehensive suite of tests for these operations? 
   Here's a good example: #61021



##########
airflow-ctl-tests/tests/airflowctl_tests/test_airflowctl_commands.py:
##########
@@ -90,6 +90,9 @@ def date_param():
     "dags update --dag-id=example_bash_operator --no-is-paused",
     # DAG Run commands
     "dagrun list --dag-id example_bash_operator --state success --limit=1",
+    # Task Instance commands
+    f'taskinstance list --dag-id=example_bash_operator --dag-run-id="manual__{ONE_DATE_PARAM}"',
+    f'taskinstance get --dag-id=example_bash_operator --dag-run-id="manual__{ONE_DATE_PARAM}" --task-id=runme_0',

Review Comment:
   The tests only cover taskinstance list and taskinstance get. The clear and update operations are untested and would benefit from integration test coverage



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(airflowctl): add task instance management support [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #61946:
URL: https://github.com/apache/airflow/pull/61946#issuecomment-4066960459

   No. We cannot approve it. FOr some reason your PR gets canceled. I recommend to re-open it, but approval will not change its status. Let me close it now - open a new one @Suraj-kumar00 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(airflowctl): add task instance management support [airflow]

Posted by "Suraj-kumar00 (via GitHub)" <gi...@apache.org>.
Suraj-kumar00 commented on PR #61946:
URL: https://github.com/apache/airflow/pull/61946#issuecomment-4064715175

   Hi @potiuk @dheerajturaga, 
   
   Could you please approve the PR i believe it needs your approval in-order to run those CI tests, please approve so that i can proceed fixing it.
   
   Thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org