ephraimbuddy commented on code in PR #26165:
URL: https://github.com/apache/airflow/pull/26165#discussion_r999646428
##########
airflow/api_connexion/openapi/v1.yaml:
##########
@@ -1144,6 +1144,35 @@ paths:
'404':
$ref: '#/components/responses/NotFound'
+ patch:
+ summary: Updates the state of a task instance
+ description: >
+ Updates the state for single task instance.
Review Comment:
```suggestion
Updates the state for single task instance.
*New in version 2.5.0*
```
##########
airflow/api_connexion/schemas/task_instance_schema.py:
##########
@@ -166,6 +166,14 @@ def validate_form(self, data, **kwargs):
raise ValidationError("Exactly one of execution_date or dag_run_id
must be provided")
+class SetSingleTaskInstanceStateFormSchema(Schema):
+ """Schema for handling the request of updating state of a single task
instance"""
+
+ dry_run = fields.Boolean(dump_default=True)
+ map_index = fields.Int(dump_default=-1)
Review Comment:
```suggestion
map_index = fields.Int(load_default=-1)
```
##########
airflow/api_connexion/openapi/v1.yaml:
##########
@@ -4424,6 +4477,14 @@ components:
required: true
description: The DAG run ID.
+ TaskInstanceID:
Review Comment:
Is this used anywhere?
##########
airflow/api_connexion/endpoints/task_instance_endpoint.py:
##########
@@ -545,3 +547,51 @@ def post_set_task_instances_state(*, dag_id: str, session:
Session = NEW_SESSION
session=session,
)
return
task_instance_reference_collection_schema.dump(TaskInstanceReferenceCollection(task_instances=tis))
+
+
[email protected]_access(
+ [
+ (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG),
+ (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_RUN),
+ (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_TASK_INSTANCE),
+ ],
+)
+@provide_session
+def patch_task_instance(
+ *, dag_id: str, dag_run_id: str, task_id: str, session: Session =
NEW_SESSION
+) -> APIResponse:
+ """Update the state of a mapped task instance."""
+ body = get_json_request_dict()
+ try:
+ data = set_single_task_instance_state_form.load(body)
+ except ValidationError as err:
+ raise BadRequest(detail=str(err.messages))
+
+ map_index = -1 if "map_index" not in data else data.get("map_index")
Review Comment:
```suggestion
map_index = data['map_index']
```
Any reason why we are not defaulting the map_index to -1 in the schema?
##########
airflow/api_connexion/endpoints/task_instance_endpoint.py:
##########
@@ -545,3 +547,51 @@ def post_set_task_instances_state(*, dag_id: str, session:
Session = NEW_SESSION
session=session,
)
return
task_instance_reference_collection_schema.dump(TaskInstanceReferenceCollection(task_instances=tis))
+
+
[email protected]_access(
+ [
+ (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG),
+ (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_RUN),
+ (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_TASK_INSTANCE),
+ ],
+)
+@provide_session
+def patch_task_instance(
+ *, dag_id: str, dag_run_id: str, task_id: str, session: Session =
NEW_SESSION
+) -> APIResponse:
+ """Update the state of a mapped task instance."""
Review Comment:
```suggestion
"""Update the state of a task instance."""
```
--
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]