Skip to content

Commit a8476cf

Browse files
committed
merge
2 parents 97138e2 + 6810a17 commit a8476cf

File tree

6 files changed

+185
-129
lines changed

6 files changed

+185
-129
lines changed

superannotate/consensus_benchmark/benchmark.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ..db.exports import prepare_export, download_export
1111
from ..analytics.common import aggregate_annotations_as_df
1212
from ..mixp.decorators import Trackable
13+
from ..db.project_api import get_project_and_folder_metadata
1314

1415
logger = logging.getLogger("superannotate-python-sdk")
1516

@@ -44,6 +45,12 @@ def benchmark(
4445
:return: Pandas DateFrame with columns (creatorEmail, QA, imageName, instanceId, className, area, attribute, folderName, score)
4546
:rtype: pandas DataFrame
4647
"""
48+
49+
if isinstance(project, dict):
50+
get_project_and_folder_metadata(project['name'])
51+
else:
52+
get_project_and_folder_metadata(project)
53+
4754
def aggregate_attributes(instance_df):
4855
def attribute_to_list(attribute_df):
4956
attribute_names = list(attribute_df["attributeName"])

superannotate/consensus_benchmark/consensus.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Main module for consensus computation
33
"""
44
import logging
5+
from ..db.project_api import get_project_and_folder_metadata
56
import tempfile
67
import pandas as pd
78
from pathlib import Path
@@ -45,6 +46,8 @@ def consensus(
4546
if annot_type not in supported_types:
4647
raise NotImplementedError
4748

49+
get_project_and_folder_metadata(project)
50+
4851
if export_root is None:
4952
with tempfile.TemporaryDirectory() as export_dir:
5053
proj_export_meta = prepare_export(project)

superannotate/db/exports.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,15 @@ def prepare_export(
131131
upload_state = upload_state_int_to_str(project.get("upload_state"))
132132

133133
if upload_state == "External" and include_fuse:
134-
logger.warning("Include fuse functionality is not supported for projects containing items attached with URLs")
134+
logger.warning(
135+
"Include fuse functionality is not supported for projects containing items attached with URLs"
136+
)
135137
include_fuse = False
136138
if project["type"] == "Video":
137139
if only_pinned:
138-
logger.warning("Pin functionality is not supported for projects containing videos attached with URLs")
140+
logger.warning(
141+
"Pin functionality is not supported for projects containing videos attached with URLs"
142+
)
139143
only_pinned, include_fuse = False, False
140144

141145
team_id, project_id = project["team_id"], project["id"]
@@ -150,8 +154,8 @@ def prepare_export(
150154
json_req = {
151155
"include": annotation_statuses,
152156
"coco": 0,
153-
"is_pinned": only_pinned,
154-
"fuse": include_fuse,
157+
"is_pinned": int(only_pinned),
158+
"fuse": int(include_fuse),
155159
"time": current_time
156160
}
157161
if folder_names is not None:

superannotate/db/project_api.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,25 @@ def get_project_metadata_bare(project_name, include_complete_image_count=False):
3636
if len(results) > 1:
3737
raise SAExistingProjectNameException(
3838
0, "Project name " + project_name +
39-
" is not unique. To use SDK please make project names unique."
39+
" is not unique. To use SDK please make project names unique."
4040
)
4141
elif len(results) == 1:
4242
res = results[0]
4343
res["type"] = common.project_type_int_to_str(res["type"])
4444
res["user_role"] = common.user_role_int_to_str(res["user_role"])
45+
current_frame = inspect.currentframe()
46+
outer_function = inspect.getframeinfo(current_frame.f_back).function
47+
outer_outer_function = inspect.getframeinfo(
48+
current_frame.f_back.f_back
49+
).function
50+
if res.get("type") and res["type"] == "Video" and (
51+
outer_function in common.VIDEO_DEPRICATED_FUNCTIONS or
52+
outer_outer_function in common.VIDEO_DEPRICATED_FUNCTIONS
53+
):
54+
raise SABaseException(
55+
0,
56+
"The function does not support projects containing videos attached with URLs"
57+
)
4558
return res
4659
else:
4760
raise SANonExistingProjectNameException(
@@ -134,11 +147,16 @@ def get_project_and_folder_metadata(project):
134147
raise SAIncorrectProjectArgument(project)
135148
current_frame = inspect.currentframe()
136149
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" \
150+
outer_outer_function = inspect.getframeinfo(
151+
current_frame.f_back.f_back
152+
).function
153+
if project.get("type") and project["type"] == "Video" \
139154
and (outer_function in common.VIDEO_DEPRICATED_FUNCTIONS
140155
or outer_outer_function in common.VIDEO_DEPRICATED_FUNCTIONS):
141-
raise SABaseException(0, "The function does not support projects containing videos attached with URLs")
156+
raise SABaseException(
157+
0,
158+
"The function does not support projects containing videos attached with URLs"
159+
)
142160
return project, folder
143161

144162

@@ -210,9 +228,9 @@ def create_folder(project, folder_name):
210228
params = {"team_id": project["team_id"], "project_id": project["id"]}
211229
name_changed = False
212230
if len(
213-
set(folder_name).intersection(
214-
common.SPECIAL_CHARACTERS_IN_PROJECT_FOLDER_NAMES
215-
)
231+
set(folder_name).intersection(
232+
common.SPECIAL_CHARACTERS_IN_PROJECT_FOLDER_NAMES
233+
)
216234
) > 0:
217235
logger.warning(
218236
"New folder name has special characters. Special characters will be replaced by underscores."

0 commit comments

Comments
 (0)