amoghrajesh commented on code in PR #46020:
URL: https://github.com/apache/airflow/pull/46020#discussion_r1931586895


##########
airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -442,6 +444,48 @@ def get_previous_successful_dagrun(
     return PrevSuccessfulDagRunResponse.model_validate(dag_run)
 
 
[email protected](
+    "/{task_instance_id}/runtime-checks",
+    status_code=status.HTTP_200_OK,
+    # TODO: Add description to the operation
+    # TODO: Add Operation ID to control the function name in the OpenAPI spec
+    # TODO: Do we need to use create_openapi_http_exception_doc here?
+    responses={
+        status.HTTP_400_BAD_REQUEST: {
+            "description": "Task Instance doesn't pass the required runtime 
checks"
+        },
+        status.HTTP_204_NO_CONTENT: {
+            "description": "Task Instance is not in a running state, cannot 
perform runtime checks."
+        },
+        status.HTTP_422_UNPROCESSABLE_ENTITY: {
+            "description": "Invalid payload for requested runtime checks on 
the Task Instance."
+        },
+    },
+)
+def ti_runtime_checks(
+    task_instance_id: UUID,
+    payload: TIRuntimeCheckPayload,
+    session: SessionDep,
+):
+    ti_id_str = str(task_instance_id)
+    task_instance = session.scalar(select(TI).where(TI.id == ti_id_str))
+    if task_instance.state != State.RUNNING:
+        return Response(status_code=status.HTTP_204_NO_CONTENT)

Review Comment:
   > I don't think it matters/is avoidable, but previously the asset checks 
were done before the task was put in to the running state right?
   
   Yeah that is right, but with the current design we have that won't be 
possible as we won't be able to handle this portion in `/run` endpoint for now. 
Its mentioned in the PR desc



-- 
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]

Reply via email to