Skip to content

Commit a72cd7e

Browse files
committed
tod
1 parent 610c541 commit a72cd7e

18 files changed

+69
-4682
lines changed

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
minversion = 3.7
33
log_cli=true
44
python_files = test_*.py
5-
addopts = -n auto --dist=loadscope
5+
;addopts = -n auto --dist=loadscope

src/superannotate/lib/app/helpers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,8 @@ def wrap_error(errors_list: List[Tuple[str, str]]) -> str:
142142
tabulation = get_tabulation()
143143
msgs = []
144144
for key, value in errors_list:
145-
msgs.append("{}{}{}".format(key, " " * (tabulation - len(key)), value))
145+
_tabulation = tabulation - len(key)
146+
if not key:
147+
key, value, _tabulation = value, "", 0
148+
msgs.append("{}{}{}".format(key, " " * _tabulation, value))
146149
return "\n".join(msgs)

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from lib.app.helpers import extract_project_folder
2121
from lib.app.helpers import get_annotation_paths
2222
from lib.app.helpers import get_name_url_duplicated_from_csv
23-
from lib.app.helpers import wrap_error
23+
from lib.app.helpers import wrap_error as wrap_validation_errors
2424
from lib.app.interface.base_interface import BaseInterfaceFacade
2525
from lib.app.interface.base_interface import TrackableMeta
2626
from lib.app.interface.types import AnnotationStatuses
@@ -2107,7 +2107,7 @@ def delete_annotations(
21072107
raise AppException(response.errors)
21082108

21092109
def validate_annotations(
2110-
self, project_type: ProjectTypes, annotations_json: Union[NotEmptyStr, Path]
2110+
self, project_type: ProjectTypes, annotations_json: Union[NotEmptyStr, Path, dict]
21112111
):
21122112
"""Validates given annotation JSON.
21132113
@@ -2120,19 +2120,20 @@ def validate_annotations(
21202120
:return: The success of the validation
21212121
:rtype: bool
21222122
"""
2123-
with open(annotations_json) as file:
2124-
annotation_data = json.loads(file.read())
2125-
response = Controller.validate_annotations(project_type, annotation_data)
2126-
response = self.controller.validate_annotations(
2127-
project_type, annotation_data
2128-
)
2129-
if response.errors:
2130-
raise AppException(response.errors)
2131-
report = response.data
2132-
if not report:
2133-
return True
2134-
print(wrap_error(report))
2135-
return False
2123+
if isinstance(annotations_json, dict):
2124+
annotation_data = annotations_json
2125+
else:
2126+
annotation_data = json.load(open(annotations_json))
2127+
response = self.controller.validate_annotations(
2128+
project_type, annotation_data
2129+
)
2130+
if response.errors:
2131+
raise AppException(response.errors)
2132+
report = response.data
2133+
if not report:
2134+
return True
2135+
print(wrap_validation_errors(report))
2136+
return False
21362137

21372138
def add_contributors_to_project(
21382139
self,

0 commit comments

Comments
 (0)