amoghrajesh opened a new pull request, #67041:
URL: https://github.com/apache/airflow/pull/67041
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
<!--
Thank you for contributing!
Please provide above a brief description of the changes made in this pull
request.
Write a good git commit message following this guide:
http://chris.beams.io/posts/git-commit/
Please make sure that your code changes are covered with tests.
And in case of new features or big changes remember to adjust the
documentation.
Feel free to ping (in general) for the review if you do not see reaction for
a few days
(72 Hours is the minimum reaction time you can expect from volunteers) - we
sometimes miss notifications.
In case of an existing issue, reference it using one of the following:
* closes: #ISSUE
* related: #ISSUE
-->
---
##### Was generative AI tooling used to co-author this PR?
<!--
If generative AI tooling has been used in the process of authoring this PR,
please
change below checkbox to `[X]` followed by the name of the tool, uncomment
the "Generated-by".
-->
- [ ] Yes (please specify the tool below)
<!--
Generated-by: [Tool Name] following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
-->
closes:
### Proposed change
Adds public REST endpoints for task state and asset state under `/api/v2`.
**Task State** — scoped to a task instance within a DAG run:
```
GET
/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/state
GET
/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/state/{key}
PUT
/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/state/{key}
DELETE
/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/state/{key}
DELETE
/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/state
```
`map_index` query param (default -1). `?all_map_indices=true` on the clear
endpoint wipes state across all mapped instances of the task.
**Asset State** — cross-run, scoped to an asset:
```
GET /api/v2/assets/{asset_id}/state
GET /api/v2/assets/{asset_id}/state/{key}
PUT /api/v2/assets/{asset_id}/state/{key}
DELETE /api/v2/assets/{asset_id}/state/{key}
DELETE /api/v2/assets/{asset_id}/state
```
URL patterns follow existing conventions — task state mirrors XCom, asset
state mirrors `/assets/{asset_id}/`.
### Testing
#### Task State APIs
1. set API
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/7c59e5ce-f360-4803-b424-0470c95b60fb"
/>
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/3c5f1b92-ce4f-40ed-99da-3d70469ca9b0"
/>
2. List API
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/c307160f-b6f1-4bc3-9d85-a4d9e89ae39d"
/>
3. get API
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/69dc2d4f-5d21-44a0-a022-7a52f69dc478"
/>
4. delete API
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/6bef5fc5-2673-4f33-be26-5824698695d1"
/>
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/f0d8ca3a-abae-4bf8-a03b-d6f3834ef8d4"
/>
5. clear API
For this first add couple of task states for mapped task
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/016e0961-1aae-4fc9-9930-547669f56162"
/>
Without `all_map_indices` flag (only current deleted)
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/51576653-657d-46a7-9fd8-86d7e0262b4b"
/>
With the `all_map_indices` flag:
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/233b6441-9bea-406e-8ccc-2c3b274888f0"
/>
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/b1b73c0a-d757-4322-aa28-35c86f8b8cc7"
/>
#### Asset State APIs
Using id=4 to test
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/b7db1d3f-1ce6-4380-a1f2-dd252a409bd1"
/>
1. set API
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/5c14956b-8e5a-4fde-a7bf-99184065bbb0"
/>
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/9cf4479e-908f-45b9-985b-f06b2733180a"
/>
2. get API
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/796269e5-ff33-40e8-9e84-d0b14c460f88"
/>
3. list API
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/7ac2f771-ad51-485b-af73-7228137a7cf5"
/>
4. delete API
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/632913ed-9b59-4386-9f8e-d93d06c98e0a"
/>
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/8217232d-ba6e-4f62-b69f-4ffc64fcfccb"
/>
5. To test clear, will add a few asset states
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/3d90c65e-5f04-4aba-afcf-f4c950df3ce8"
/>
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/74304187-3c3d-4882-adbf-1a6cee77ac87"
/>
All clear!
<img width="2101" height="1222" alt="image"
src="https://github.com/user-attachments/assets/9ae7a223-1697-4c49-8bd1-58daed0720d6"
/>
---
* 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`, in
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
You can add this file in a follow-up commit after the PR is created so you
know the PR number.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]