@@ -936,7 +936,7 @@ def create_image_task(
936936 if annotations :
937937 for annotation in annotations :
938938 annotation ["content" ] = name
939- payload ["annotations" ] = annotations
939+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
940940 if tags :
941941 payload ["tags" ] = tags
942942
@@ -992,7 +992,7 @@ def create_integrated_image_task(
992992 if annotations :
993993 for annotation in annotations :
994994 annotation ["content" ] = file_path
995- payload ["annotations" ] = annotations
995+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
996996 if tags :
997997 payload ["tags" ] = tags
998998
@@ -1054,7 +1054,7 @@ def create_image_classification_task(
10541054 if priority is not None :
10551055 payload ["priority" ] = priority
10561056 if attributes :
1057- payload ["attributes" ] = attributes
1057+ payload ["attributes" ] = delete_extra_attributes_parameter ( attributes )
10581058 if tags :
10591059 payload ["tags" ] = tags
10601060
@@ -1114,7 +1114,7 @@ def create_integrated_image_classification_task(
11141114 if priority is not None :
11151115 payload ["priority" ] = priority
11161116 if attributes :
1117- payload ["attributes" ] = attributes
1117+ payload ["attributes" ] = delete_extra_attributes_parameter ( attributes )
11181118 if tags :
11191119 payload ["tags" ] = tags
11201120
@@ -1204,7 +1204,7 @@ def create_sequential_image_task(
12041204 if priority is not None :
12051205 payload ["priority" ] = priority
12061206 if annotations :
1207- payload ["annotations" ] = annotations
1207+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
12081208 if tags :
12091209 payload ["tags" ] = tags
12101210
@@ -1273,7 +1273,7 @@ def create_video_task(
12731273 if annotations :
12741274 for annotation in annotations :
12751275 annotation ["content" ] = name
1276- payload ["annotations" ] = annotations
1276+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
12771277 if tags :
12781278 payload ["tags" ] = tags
12791279
@@ -1340,7 +1340,7 @@ def create_video_classification_task(
13401340 if priority is not None :
13411341 payload ["priority" ] = priority
13421342 if attributes :
1343- payload ["attributes" ] = attributes
1343+ payload ["attributes" ] = delete_extra_attributes_parameter ( attributes )
13441344 if tags :
13451345 payload ["tags" ] = tags
13461346
@@ -1402,7 +1402,7 @@ def create_text_task(
14021402 if annotations :
14031403 for annotation in annotations :
14041404 annotation ["content" ] = name
1405- payload ["annotations" ] = annotations
1405+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
14061406 if tags :
14071407 payload ["tags" ] = tags
14081408
@@ -1462,7 +1462,7 @@ def create_text_classification_task(
14621462 if priority is not None :
14631463 payload ["priority" ] = priority
14641464 if attributes :
1465- payload ["attributes" ] = attributes
1465+ payload ["attributes" ] = delete_extra_attributes_parameter ( attributes )
14661466 if tags :
14671467 payload ["tags" ] = tags
14681468
@@ -1528,7 +1528,7 @@ def create_audio_task(
15281528 if annotations :
15291529 for annotation in annotations :
15301530 annotation ["content" ] = name
1531- payload ["annotations" ] = annotations
1531+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
15321532 if tags :
15331533 payload ["tags" ] = tags
15341534
@@ -1592,7 +1592,7 @@ def create_audio_classification_task(
15921592 if priority is not None :
15931593 payload ["priority" ] = priority
15941594 if attributes :
1595- payload ["attributes" ] = attributes
1595+ payload ["attributes" ] = delete_extra_attributes_parameter ( attributes )
15961596 if tags :
15971597 payload ["tags" ] = tags
15981598
@@ -1707,7 +1707,7 @@ def create_pcd_task(
17071707 if annotations :
17081708 for annotation in annotations :
17091709 annotation ["content" ] = name
1710- payload ["annotations" ] = annotations
1710+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
17111711 if tags :
17121712 payload ["tags" ] = tags
17131713
@@ -1797,7 +1797,7 @@ def create_sequential_pcd_task(
17971797 if priority is not None :
17981798 payload ["priority" ] = priority
17991799 if annotations :
1800- payload ["annotations" ] = annotations
1800+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
18011801 if tags :
18021802 payload ["tags" ] = tags
18031803
@@ -1901,7 +1901,7 @@ def update_image_task(
19011901 # Since the content name is not passed in the sdk update api,
19021902 # the content will be filled on the server side.
19031903 annotation ["content" ] = ""
1904- payload ["annotations" ] = annotations
1904+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
19051905
19061906 self .__fill_assign_users (payload , ** kwargs )
19071907
@@ -1949,7 +1949,7 @@ def update_image_classification_task(
19491949 if priority is not None :
19501950 payload ["priority" ] = priority
19511951 if attributes :
1952- payload ["attributes" ] = attributes
1952+ payload ["attributes" ] = delete_extra_attributes_parameter ( attributes )
19531953 if tags :
19541954 payload ["tags" ] = tags
19551955
@@ -2001,7 +2001,7 @@ def update_sequential_image_task(
20012001 if tags :
20022002 payload ["tags" ] = tags
20032003 if annotations :
2004- payload ["annotations" ] = annotations
2004+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
20052005
20062006 self .__fill_assign_users (payload , ** kwargs )
20072007
@@ -2053,7 +2053,7 @@ def update_video_task(
20532053 if annotations :
20542054 for annotation in annotations :
20552055 annotation ["content" ] = ""
2056- payload ["annotations" ] = annotations
2056+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
20572057
20582058 self .__fill_assign_users (payload , ** kwargs )
20592059
@@ -2101,7 +2101,7 @@ def update_video_classification_task(
21012101 if priority is not None :
21022102 payload ["priority" ] = priority
21032103 if attributes :
2104- payload ["attributes" ] = attributes
2104+ payload ["attributes" ] = delete_extra_attributes_parameter ( attributes )
21052105 if tags :
21062106 payload ["tags" ] = tags
21072107
@@ -2155,7 +2155,7 @@ def update_text_task(
21552155 if annotations :
21562156 for annotation in annotations :
21572157 annotation ["content" ] = ""
2158- payload ["annotations" ] = annotations
2158+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
21592159
21602160 self .__fill_assign_users (payload , ** kwargs )
21612161
@@ -2203,7 +2203,7 @@ def update_text_classification_task(
22032203 if priority is not None :
22042204 payload ["priority" ] = priority
22052205 if attributes :
2206- payload ["attributes" ] = attributes
2206+ payload ["attributes" ] = delete_extra_attributes_parameter ( attributes )
22072207 if tags :
22082208 payload ["tags" ] = tags
22092209
@@ -2257,7 +2257,7 @@ def update_audio_task(
22572257 if annotations :
22582258 for annotation in annotations :
22592259 annotation ["content" ] = ""
2260- payload ["annotations" ] = annotations
2260+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
22612261
22622262 self .__fill_assign_users (payload , ** kwargs )
22632263
@@ -2305,7 +2305,7 @@ def update_audio_classification_task(
23052305 if priority is not None :
23062306 payload ["priority" ] = priority
23072307 if attributes :
2308- payload ["attributes" ] = attributes
2308+ payload ["attributes" ] = delete_extra_attributes_parameter ( attributes )
23092309 if tags :
23102310 payload ["tags" ] = tags
23112311
@@ -2361,7 +2361,7 @@ def update_pcd_task(
23612361 # Since the content name is not passed in the sdk update api,
23622362 # the content will be filled on the server side.
23632363 annotation ["content" ] = ""
2364- payload ["annotations" ] = annotations
2364+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
23652365
23662366 self .__fill_assign_users (payload , ** kwargs )
23672367
@@ -2415,7 +2415,7 @@ def update_sequential_pcd_task(
24152415 # Since the content name is not passed in the sdk update api,
24162416 # the content will be filled on the server side.
24172417 annotation ["content" ] = ""
2418- payload ["annotations" ] = annotations
2418+ payload ["annotations" ] = delete_extra_annotations_parameter ( annotations )
24192419
24202420 self .__fill_assign_users (payload , ** kwargs )
24212421
@@ -4299,3 +4299,24 @@ def get_histories(
42994299 params ["limit" ] = limit
43004300
43014301 return self .api .get_request (endpoint , params = params )
4302+
4303+ def delete_extra_annotations_parameter (annotations : list ) -> list :
4304+ for annotation in annotations :
4305+ annotation .pop ("id" , None )
4306+ annotation .pop ("title" , None )
4307+ annotation .pop ("color" , None )
4308+ for keypoint in annotation .get ("keypoints" , []):
4309+ keypoint .pop ("edges" , None )
4310+ keypoint .pop ("name" , None )
4311+ annotation ["attributes" ] = delete_extra_attributes_parameter (
4312+ annotation .get ("attributes" , [])
4313+ )
4314+ return annotations
4315+
4316+
4317+ def delete_extra_attributes_parameter (attributes : list ) -> list :
4318+ for attribute in attributes :
4319+ attribute .pop ("title" , None )
4320+ attribute .pop ("name" , None )
4321+ attribute .pop ("type" , None )
4322+ return attributes
0 commit comments