1313from typing import Union
1414
1515import boto3
16- import lib .core as constances
16+ import lib .core as constants
1717from lib .app .annotation_helpers import add_annotation_bbox_to_json
1818from lib .app .annotation_helpers import add_annotation_comment_to_json
1919from lib .app .annotation_helpers import add_annotation_point_to_json
6262
6363
6464class SAClient (BaseInterfaceFacade , metaclass = TrackableMeta ):
65+ def __init__ (
66+ self ,
67+ token : str = None ,
68+ config_path : str = constants .CONFIG_PATH ,
69+ ):
70+ super ().__init__ (token , config_path )
71+
6572 def get_team_metadata (self ):
6673 """Returns team metadata
6774
@@ -415,11 +422,11 @@ def copy_image(
415422 ).data
416423
417424 if destination_project_metadata ["project" ].type in [
418- constances .ProjectType .VIDEO .value ,
419- constances .ProjectType .DOCUMENT .value ,
425+ constants .ProjectType .VIDEO .value ,
426+ constants .ProjectType .DOCUMENT .value ,
420427 ] or source_project_metadata ["project" ].type in [
421- constances .ProjectType .VIDEO .value ,
422- constances .ProjectType .DOCUMENT .value ,
428+ constants .ProjectType .VIDEO .value ,
429+ constants .ProjectType .DOCUMENT .value ,
423430 ]:
424431 raise AppException (
425432 LIMITED_FUNCTIONS [source_project_metadata ["project" ].type ]
@@ -738,8 +745,8 @@ def assign_images(
738745 project = self .controller .get_project_metadata (project_name ).data
739746
740747 if project ["project" ].type in [
741- constances .ProjectType .VIDEO .value ,
742- constances .ProjectType .DOCUMENT .value ,
748+ constants .ProjectType .VIDEO .value ,
749+ constants .ProjectType .DOCUMENT .value ,
743750 ]:
744751 raise AppException (LIMITED_FUNCTIONS [project ["project" ].type ])
745752
@@ -864,12 +871,12 @@ def upload_images_from_folder_to_project(
864871 folder_path : Union [NotEmptyStr , Path ],
865872 extensions : Optional [
866873 Union [List [NotEmptyStr ], Tuple [NotEmptyStr ]]
867- ] = constances .DEFAULT_IMAGE_EXTENSIONS ,
874+ ] = constants .DEFAULT_IMAGE_EXTENSIONS ,
868875 annotation_status = "NotStarted" ,
869876 from_s3_bucket = None ,
870877 exclude_file_patterns : Optional [
871878 Iterable [NotEmptyStr ]
872- ] = constances .DEFAULT_FILE_EXCLUDE_PATTERNS ,
879+ ] = constants .DEFAULT_FILE_EXCLUDE_PATTERNS ,
873880 recursive_subfolders : Optional [StrictBool ] = False ,
874881 image_quality_in_editor : Optional [str ] = None ,
875882 ):
@@ -926,7 +933,7 @@ def upload_images_from_folder_to_project(
926933
927934 if exclude_file_patterns :
928935 exclude_file_patterns = list (exclude_file_patterns ) + list (
929- constances .DEFAULT_FILE_EXCLUDE_PATTERNS
936+ constants .DEFAULT_FILE_EXCLUDE_PATTERNS
930937 )
931938 exclude_file_patterns = list (set (exclude_file_patterns ))
932939
@@ -1082,12 +1089,12 @@ def prepare_export(
10821089 folders = folder_names
10831090 if not annotation_statuses :
10841091 annotation_statuses = [
1085- constances .AnnotationStatus .NOT_STARTED .name ,
1086- constances .AnnotationStatus .IN_PROGRESS .name ,
1087- constances .AnnotationStatus .QUALITY_CHECK .name ,
1088- constances .AnnotationStatus .RETURNED .name ,
1089- constances .AnnotationStatus .COMPLETED .name ,
1090- constances .AnnotationStatus .SKIPPED .name ,
1092+ constants .AnnotationStatus .NOT_STARTED .name ,
1093+ constants .AnnotationStatus .IN_PROGRESS .name ,
1094+ constants .AnnotationStatus .QUALITY_CHECK .name ,
1095+ constants .AnnotationStatus .RETURNED .name ,
1096+ constants .AnnotationStatus .COMPLETED .name ,
1097+ constants .AnnotationStatus .SKIPPED .name ,
10911098 ]
10921099 response = self .controller .prepare_export (
10931100 project_name = project_name ,
@@ -1106,7 +1113,7 @@ def upload_videos_from_folder_to_project(
11061113 folder_path : Union [NotEmptyStr , Path ],
11071114 extensions : Optional [
11081115 Union [Tuple [NotEmptyStr ], List [NotEmptyStr ]]
1109- ] = constances .DEFAULT_VIDEO_EXTENSIONS ,
1116+ ] = constants .DEFAULT_VIDEO_EXTENSIONS ,
11101117 exclude_file_patterns : Optional [List [NotEmptyStr ]] = (),
11111118 recursive_subfolders : Optional [StrictBool ] = False ,
11121119 target_fps : Optional [int ] = None ,
@@ -1593,8 +1600,8 @@ def upload_preannotations_from_folder_to_project(
15931600 project_folder_name = project_name + (f"/{ folder_name } " if folder_name else "" )
15941601 project = self .controller .get_project_metadata (project_name ).data
15951602 if project ["project" ].type in [
1596- constances .ProjectType .VIDEO .value ,
1597- constances .ProjectType .DOCUMENT .value ,
1603+ constants .ProjectType .VIDEO .value ,
1604+ constants .ProjectType .DOCUMENT .value ,
15981605 ]:
15991606 raise AppException (LIMITED_FUNCTIONS [project ["project" ].type ])
16001607 if recursive_subfolders :
@@ -1649,8 +1656,8 @@ def upload_image_annotations(
16491656
16501657 project = self .controller .get_project_metadata (project_name ).data
16511658 if project ["project" ].type in [
1652- constances .ProjectType .VIDEO .value ,
1653- constances .ProjectType .DOCUMENT .value ,
1659+ constants .ProjectType .VIDEO .value ,
1660+ constants .ProjectType .DOCUMENT .value ,
16541661 ]:
16551662 raise AppException (LIMITED_FUNCTIONS [project ["project" ].type ])
16561663
@@ -1677,7 +1684,7 @@ def upload_image_annotations(
16771684 mask = mask ,
16781685 verbose = verbose ,
16791686 )
1680- if response .errors and not response .errors == constances .INVALID_JSON_MESSAGE :
1687+ if response .errors and not response .errors == constants .INVALID_JSON_MESSAGE :
16811688 raise AppException (response .errors )
16821689
16831690 def download_model (self , model : MLModel , output_dir : Union [str , Path ]):
@@ -1735,8 +1742,8 @@ def benchmark(
17351742
17361743 project = self .controller .get_project_metadata (project_name ).data
17371744 if project ["project" ].type in [
1738- constances .ProjectType .VIDEO .value ,
1739- constances .ProjectType .DOCUMENT .value ,
1745+ constants .ProjectType .VIDEO .value ,
1746+ constants .ProjectType .DOCUMENT .value ,
17401747 ]:
17411748 raise AppException (LIMITED_FUNCTIONS [project ["project" ].type ])
17421749
@@ -1887,8 +1894,8 @@ def add_annotation_bbox_to_image(
18871894 project_name , folder_name = extract_project_folder (project )
18881895 project = self .controller .get_project_metadata (project_name ).data
18891896 if project ["project" ].type in [
1890- constances .ProjectType .VIDEO .value ,
1891- constances .ProjectType .DOCUMENT .value ,
1897+ constants .ProjectType .VIDEO .value ,
1898+ constants .ProjectType .DOCUMENT .value ,
18921899 ]:
18931900 raise AppException (LIMITED_FUNCTIONS [project ["project" ].type ])
18941901 response = self .controller .get_annotations (
@@ -1945,8 +1952,8 @@ def add_annotation_point_to_image(
19451952 project_name , folder_name = extract_project_folder (project )
19461953 project = self .controller .get_project_metadata (project_name ).data
19471954 if project ["project" ].type in [
1948- constances .ProjectType .VIDEO .value ,
1949- constances .ProjectType .DOCUMENT .value ,
1955+ constants .ProjectType .VIDEO .value ,
1956+ constants .ProjectType .DOCUMENT .value ,
19501957 ]:
19511958 raise AppException (LIMITED_FUNCTIONS [project ["project" ].type ])
19521959 response = self .controller .get_annotations (
@@ -2000,8 +2007,8 @@ def add_annotation_comment_to_image(
20002007 project_name , folder_name = extract_project_folder (project )
20012008 project = self .controller .get_project_metadata (project_name ).data
20022009 if project ["project" ].type in [
2003- constances .ProjectType .VIDEO .value ,
2004- constances .ProjectType .DOCUMENT .value ,
2010+ constants .ProjectType .VIDEO .value ,
2011+ constants .ProjectType .DOCUMENT .value ,
20052012 ]:
20062013 raise AppException (LIMITED_FUNCTIONS [project ["project" ].type ])
20072014 response = self .controller .get_annotations (
@@ -2187,8 +2194,8 @@ def aggregate_annotations_as_df(
21872194 :rtype: pandas DataFrame
21882195 """
21892196 if project_type in (
2190- constances .ProjectType .VECTOR .name ,
2191- constances .ProjectType .PIXEL .name ,
2197+ constants .ProjectType .VECTOR .name ,
2198+ constants .ProjectType .PIXEL .name ,
21922199 ):
21932200 from superannotate .lib .app .analytics .common import (
21942201 aggregate_image_annotations_as_df ,
@@ -2202,8 +2209,8 @@ def aggregate_annotations_as_df(
22022209 folder_names = folder_names ,
22032210 )
22042211 elif project_type in (
2205- constances .ProjectType .VIDEO .name ,
2206- constances .ProjectType .DOCUMENT .name ,
2212+ constants .ProjectType .VIDEO .name ,
2213+ constants .ProjectType .DOCUMENT .name ,
22072214 ):
22082215 from superannotate .lib .app .analytics .aggregators import DataAggregator
22092216
@@ -2214,21 +2221,21 @@ def aggregate_annotations_as_df(
22142221 ).aggregate_annotations_as_df ()
22152222
22162223 def delete_annotations (
2217- self , project : NotEmptyStr , image_names : Optional [List [NotEmptyStr ]] = None
2224+ self , project : NotEmptyStr , item_names : Optional [List [NotEmptyStr ]] = None
22182225 ):
22192226 """
2220- Delete image annotations from a given list of images .
2227+ Delete item annotations from a given list of items .
22212228
22222229 :param project: project name or folder path (e.g., "project1/folder1")
22232230 :type project: str
2224- :param image_names : image names. If None, all image annotations from a given project/folder will be deleted.
2225- :type image_names : list of strs
2231+ :param item_names : image names. If None, all image annotations from a given project/folder will be deleted.
2232+ :type item_names : list of strs
22262233 """
22272234
22282235 project_name , folder_name = extract_project_folder (project )
22292236
22302237 response = self .controller .delete_annotations (
2231- project_name = project_name , folder_name = folder_name , item_names = image_names
2238+ project_name = project_name , folder_name = folder_name , item_names = item_names
22322239 )
22332240 if response .errors :
22342241 raise AppException (response .errors )
0 commit comments