This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new fba6f86ed7 Allow skipped task state task_instance_schema.py (#31421)
fba6f86ed7 is described below

commit fba6f86ed7e59c166d0cf7717f1734ae30ba4d9c
Author: JoranDox <[email protected]>
AuthorDate: Thu Jun 8 22:57:17 2023 +0200

    Allow skipped task state task_instance_schema.py (#31421)
    
    
    
    ---------
    
    Co-authored-by: Hussein Awala <[email protected]>
---
 airflow/api_connexion/openapi/v1.yaml                    |  3 +++
 airflow/api_connexion/schemas/task_instance_schema.py    | 16 +++++++++++++---
 airflow/www/static/js/types/api-generated.ts             |  4 ++--
 .../endpoints/test_task_instance_endpoint.py             |  6 ++++--
 4 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/airflow/api_connexion/openapi/v1.yaml 
b/airflow/api_connexion/openapi/v1.yaml
index 5bb56f97c5..8bf976aa46 100644
--- a/airflow/api_connexion/openapi/v1.yaml
+++ b/airflow/api_connexion/openapi/v1.yaml
@@ -4265,6 +4265,7 @@ components:
           enum:
             - success
             - failed
+            - skipped
 
     UpdateTaskInstance:
       type: object
@@ -4282,6 +4283,8 @@ components:
           enum:
             - success
             - failed
+            - skipped
+
     SetTaskInstanceNote:
       type: object
       required:
diff --git a/airflow/api_connexion/schemas/task_instance_schema.py 
b/airflow/api_connexion/schemas/task_instance_schema.py
index 970ef9a0fd..359294f5d4 100644
--- a/airflow/api_connexion/schemas/task_instance_schema.py
+++ b/airflow/api_connexion/schemas/task_instance_schema.py
@@ -30,7 +30,7 @@ from airflow.api_connexion.schemas.sla_miss_schema import 
SlaMissSchema
 from airflow.api_connexion.schemas.trigger_schema import TriggerSchema
 from airflow.models import SlaMiss, TaskInstance
 from airflow.utils.helpers import exactly_one
-from airflow.utils.state import State
+from airflow.utils.state import TaskInstanceState
 
 
 class TaskInstanceSchema(SQLAlchemySchema):
@@ -158,7 +158,12 @@ class SetTaskInstanceStateFormSchema(Schema):
     include_downstream = fields.Boolean(required=True)
     include_future = fields.Boolean(required=True)
     include_past = fields.Boolean(required=True)
-    new_state = TaskInstanceStateField(required=True, 
validate=validate.OneOf([State.SUCCESS, State.FAILED]))
+    new_state = TaskInstanceStateField(
+        required=True,
+        validate=validate.OneOf(
+            [TaskInstanceState.SUCCESS, TaskInstanceState.FAILED, 
TaskInstanceState.SKIPPED]
+        ),
+    )
 
     @validates_schema
     def validate_form(self, data, **kwargs):
@@ -171,7 +176,12 @@ class SetSingleTaskInstanceStateFormSchema(Schema):
     """Schema for handling the request of updating state of a single task 
instance."""
 
     dry_run = fields.Boolean(dump_default=True)
-    new_state = TaskInstanceStateField(required=True, 
validate=validate.OneOf([State.SUCCESS, State.FAILED]))
+    new_state = TaskInstanceStateField(
+        required=True,
+        validate=validate.OneOf(
+            [TaskInstanceState.SUCCESS, TaskInstanceState.FAILED, 
TaskInstanceState.SKIPPED]
+        ),
+    )
 
 
 class TaskInstanceReferenceSchema(Schema):
diff --git a/airflow/www/static/js/types/api-generated.ts 
b/airflow/www/static/js/types/api-generated.ts
index 75e1a650f6..347f76e08f 100644
--- a/airflow/www/static/js/types/api-generated.ts
+++ b/airflow/www/static/js/types/api-generated.ts
@@ -1874,7 +1874,7 @@ export interface components {
        * @description Expected new state.
        * @enum {string}
        */
-      new_state?: "success" | "failed";
+      new_state?: "success" | "failed" | "skipped";
     };
     UpdateTaskInstance: {
       /**
@@ -1888,7 +1888,7 @@ export interface components {
        * @description Expected new state.
        * @enum {string}
        */
-      new_state?: "success" | "failed";
+      new_state?: "success" | "failed" | "skipped";
     };
     SetTaskInstanceNote: {
       /** @description The custom note to set for this Task Instance. */
diff --git a/tests/api_connexion/endpoints/test_task_instance_endpoint.py 
b/tests/api_connexion/endpoints/test_task_instance_endpoint.py
index 9f1f74df55..a8c4c8b10a 100644
--- a/tests/api_connexion/endpoints/test_task_instance_endpoint.py
+++ b/tests/api_connexion/endpoints/test_task_instance_endpoint.py
@@ -1803,14 +1803,16 @@ class TestPatchTaskInstance(TestTaskInstanceEndpoint):
                     "dry_run": True,
                     "new_state": "failede",
                 },
-                f"'failede' is not one of ['{State.SUCCESS}', 
'{State.FAILED}'] - 'new_state'",
+                f"'failede' is not one of ['{State.SUCCESS}', 
'{State.FAILED}', '{State.SKIPPED}']"
+                " - 'new_state'",
             ),
             (
                 {
                     "dry_run": True,
                     "new_state": "queued",
                 },
-                f"'queued' is not one of ['{State.SUCCESS}', '{State.FAILED}'] 
- 'new_state'",
+                f"'queued' is not one of ['{State.SUCCESS}', '{State.FAILED}', 
'{State.SKIPPED}']"
+                " - 'new_state'",
             ),
         ],
     )

Reply via email to