Skip to content

Commit e077a7d

Browse files
koki.murasawakoki.murasawa
authored andcommitted
Moved delete_extra_parameters function to a more appropriate location
1 parent bc597b0 commit e077a7d

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

fastlabel/__init__.py

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ def create_image_task(
936936
if annotations:
937937
for annotation in annotations:
938938
annotation["content"] = name
939-
payload["annotations"] = converters.delete_extra_annotations_parameter(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"] = converters.delete_extra_annotations_parameter(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"] = converters._delete_extra_attributes_parameter(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"] = converters._delete_extra_attributes_parameter(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"] = converters.delete_extra_annotations_parameter(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"] = converters.delete_extra_annotations_parameter(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"] = converters._delete_extra_attributes_parameter(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"] = converters.delete_extra_annotations_parameter(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"] = converters._delete_extra_attributes_parameter(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"] = converters.delete_extra_annotations_parameter(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"] = converters._delete_extra_attributes_parameter(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"] = converters.delete_extra_annotations_parameter(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"] = converters.delete_extra_annotations_parameter(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"] = converters.delete_extra_annotations_parameter(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"] = converters._delete_extra_attributes_parameter(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"] = converters.delete_extra_annotations_parameter(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"] = converters.delete_extra_annotations_parameter(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"] = converters._delete_extra_attributes_parameter(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"] = converters.delete_extra_annotations_parameter(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"] = converters._delete_extra_attributes_parameter(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"] = converters.delete_extra_annotations_parameter(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"] = converters._delete_extra_attributes_parameter(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"] = converters.delete_extra_annotations_parameter(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"] = converters.delete_extra_annotations_parameter(annotations)
2418+
payload["annotations"] = delete_extra_annotations_parameter(annotations)
24192419

24202420
self.__fill_assign_users(payload, **kwargs)
24212421

@@ -4273,3 +4273,24 @@ def get_histories(
42734273
params["limit"] = limit
42744274

42754275
return self.api.get_request(endpoint, params=params)
4276+
4277+
def delete_extra_annotations_parameter(annotations: list) -> list:
4278+
for annotation in annotations:
4279+
annotation.pop("id", None)
4280+
annotation.pop("title", None)
4281+
annotation.pop("color", None)
4282+
for keypoint in annotation.get("keypoints", []):
4283+
keypoint.pop("edges", None)
4284+
keypoint.pop("name", None)
4285+
annotation["attributes"] = delete_extra_attributes_parameter(
4286+
annotation.get("attributes", [])
4287+
)
4288+
return annotations
4289+
4290+
4291+
def delete_extra_attributes_parameter(attributes: list) -> list:
4292+
for attribute in attributes:
4293+
attribute.pop("title", None)
4294+
attribute.pop("name", None)
4295+
attribute.pop("type", None)
4296+
return attributes

fastlabel/converters.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,24 +1139,3 @@ def _get_coco_annotation_attributes(annotation: dict) -> Dict[str, AttributeValu
11391139
coco_attributes[attribute["key"]] = attribute["value"]
11401140
return coco_attributes
11411141

1142-
1143-
def delete_extra_annotations_parameter(annotations: list) -> list:
1144-
for annotation in annotations:
1145-
annotation.pop("id", None)
1146-
annotation.pop("title", None)
1147-
annotation.pop("color", None)
1148-
for keypoint in annotation.get("keypoints", []):
1149-
keypoint.pop("edges", None)
1150-
keypoint.pop("name", None)
1151-
annotation["attributes"] = _delete_extra_attributes_parameter(
1152-
annotation.get("attributes", [])
1153-
)
1154-
return annotations
1155-
1156-
1157-
def _delete_extra_attributes_parameter(attributes: list) -> list:
1158-
for attribute in attributes:
1159-
attribute.pop("title", None)
1160-
attribute.pop("name", None)
1161-
attribute.pop("type", None)
1162-
return attributes

0 commit comments

Comments
 (0)