Skip to content

Commit e3d9091

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
added depricated functions validation
1 parent 37aa83b commit e3d9091

File tree

4 files changed

+63
-22
lines changed

4 files changed

+63
-22
lines changed

superannotate/api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def init(self, config_location=None):
8989
req_type='GET',
9090
path=f'/team/{self.team_id}',
9191
)
92-
9392
self.user_id = response.json().get('creator_id', None)
9493
self.team_name = response.json().get('name', None)
9594

superannotate/common.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,46 @@
5959
"Semantic Segmentation for Pixel Projects": "semantic_segmentation_pixel"
6060
}
6161

62+
VIDEO_DEPRICATED_FUNCTIONS = [
63+
"upload_images_from_folder_to_project",
64+
"get_image_metadata",
65+
"search_images",
66+
"upload_images_to_project",
67+
"upload_annotations_from_folder_to_project",
68+
"upload_image_annotations",
69+
"download_image",
70+
"download_image_annotations",
71+
"get_image_annotations",
72+
"set_image_annotation_status",
73+
"aggregate_annotations_as_df",
74+
"attach_image_urls_to_project",
75+
"clone_project",
76+
"copy_image",
77+
"export_annotation",
78+
"upload_image_to_project",
79+
"upload_video_to_project",
80+
"add_annotation_bbox_to_image",
81+
"assign_images",
82+
"delete_images",
83+
"get_project_image_count",
84+
"set_project_workflow",
85+
"upload_preannotations_from_folder_to_project",
86+
"upload_videos_from_folder_to_project",
87+
"add_annotation_comment_to_image",
88+
"add_annotation_point_to_image",
89+
"benchmark",
90+
"class_distribution",
91+
"consensus",
92+
"convert_project_type",
93+
"copy_images",
94+
"get_project_workflow",
95+
"move_image",
96+
"move_images",
97+
"set_images_annotation_statuses",
98+
"set_project_default_image_quality_in_editor",
99+
"upload_images_from_google_cloud_to_project",
100+
]
101+
62102

63103
def prediction_segmentation_status_from_str_to_int(status):
64104
return _PREDICTION_SEGMENTATION_STATUSES[status]
@@ -324,7 +364,7 @@ def write_to_json(output_path, json_data):
324364

325365

326366
def tqdm_converter(
327-
total_num, images_converted, images_not_converted, finish_event
367+
total_num, images_converted, images_not_converted, finish_event
328368
):
329369
with tqdm(total=total_num) as pbar:
330370
while True:

superannotate/db/exports.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,17 @@ def prepare_export(
127127
"""
128128
if not isinstance(project, dict):
129129
project = get_project_metadata_bare(project)
130-
if project["type"] == "Video":
131-
if include_fuse or only_pinned:
132-
raise SABaseException(
133-
0,
134-
"The function does not support include fuse and pin arguments "
135-
"for projects containing videos attached with URLs"
136-
)
137130

138131
upload_state = upload_state_int_to_str(project.get("upload_state"))
139-
if upload_state == "External" and include_fuse == True:
140-
logger.info(
141-
"Include fuse functionality is not supported for projects containing images attached with URLs"
142-
)
132+
133+
if upload_state == "External" and include_fuse:
134+
logger.warning("Include fuse functionality is not supported for projects containing items attached with URLs")
143135
include_fuse = False
136+
if project["type"] == "Video":
137+
if only_pinned:
138+
logger.warning("Pin functionality is not supported for projects containing videos attached with URLs")
139+
only_pinned, include_fuse = False, False
140+
144141
team_id, project_id = project["team_id"], project["id"]
145142
if annotation_statuses is None:
146143
annotation_statuses = [2, 3, 4, 5]
@@ -153,13 +150,10 @@ def prepare_export(
153150
json_req = {
154151
"include": annotation_statuses,
155152
"coco": 0,
153+
"is_pinned": only_pinned,
154+
"fuse": include_fuse,
156155
"time": current_time
157156
}
158-
if project["type"] != "Video":
159-
json_req["fuse"] = int(include_fuse)
160-
json_req["is_pinned"] = int(only_pinned)
161-
json_req["coco"] = 0
162-
163157
if folder_names is not None:
164158
json_req["folder_names"] = folder_names
165159
params = {'team_id': team_id, 'project_id': project_id}

superannotate/db/project_api.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import inspect
23

34
from .. import common
45
from ..api import API
@@ -35,7 +36,7 @@ def get_project_metadata_bare(project_name, include_complete_image_count=False):
3536
if len(results) > 1:
3637
raise SAExistingProjectNameException(
3738
0, "Project name " + project_name +
38-
" is not unique. To use SDK please make project names unique."
39+
" is not unique. To use SDK please make project names unique."
3940
)
4041
elif len(results) == 1:
4142
res = results[0]
@@ -131,6 +132,13 @@ def get_project_and_folder_metadata(project):
131132
raise SAIncorrectProjectArgument(project)
132133
else:
133134
raise SAIncorrectProjectArgument(project)
135+
current_frame = inspect.currentframe()
136+
outer_function = inspect.getframeinfo(current_frame.f_back).function
137+
outer_outer_function = inspect.getframeinfo(current_frame.f_back.f_back).function
138+
if project["type"] == "Video" \
139+
and (outer_function in common.VIDEO_DEPRICATED_FUNCTIONS
140+
or outer_outer_function in common.VIDEO_DEPRICATED_FUNCTIONS):
141+
raise SABaseException(0, "The function does not support projects containing videos attached with URLs")
134142
return project, folder
135143

136144

@@ -202,9 +210,9 @@ def create_folder(project, folder_name):
202210
params = {"team_id": project["team_id"], "project_id": project["id"]}
203211
name_changed = False
204212
if len(
205-
set(folder_name).intersection(
206-
common.SPECIAL_CHARACTERS_IN_PROJECT_FOLDER_NAMES
207-
)
213+
set(folder_name).intersection(
214+
common.SPECIAL_CHARACTERS_IN_PROJECT_FOLDER_NAMES
215+
)
208216
) > 0:
209217
logger.warning(
210218
"New folder name has special characters. Special characters will be replaced by underscores."

0 commit comments

Comments
 (0)