11import os
2- import shutil
32import sys
43import tempfile
54from pathlib import Path
65from typing import Any
76from typing import Optional
87
9- import lib as sa_lib
108import lib .core as constances
119from lib .app .input_converters .conversion import import_annotation
1210from lib .app .interface .sdk_interface import SAClient
@@ -31,9 +29,9 @@ def version():
3129
3230 @staticmethod
3331 def init (
34- token : str ,
35- logging_level : str = "INFO" ,
36- logging_path : str = constances .LOG_FILE_LOCATION ,
32+ token : str ,
33+ logging_level : str = "INFO" ,
34+ logging_path : str = constances .LOG_FILE_LOCATION ,
3735 ):
3836 """
3937 To initialize CLI (and SDK) with team token
@@ -55,7 +53,7 @@ def init(
5553 if Path (constances .CONFIG_INI_FILE_LOCATION ).exists ():
5654 operation = "updated"
5755 if not input (
58- f"File { constances .CONFIG_INI_FILE_LOCATION } exists. Do you want to overwrite? [y/n] : "
56+ f"File { constances .CONFIG_INI_FILE_LOCATION } exists. Do you want to overwrite? [y/n] : "
5957 ).lower () in ("y" , "yes" ):
6058 return
6159 else :
@@ -86,14 +84,14 @@ def create_folder(self, project: str, name: str):
8684 sys .exit (0 )
8785
8886 def upload_images (
89- self ,
90- project : str ,
91- folder : str ,
92- extensions : str = constances .DEFAULT_IMAGE_EXTENSIONS ,
93- set_annotation_status : str = constances .AnnotationStatus .NOT_STARTED .name ,
94- exclude_file_patterns = constances .DEFAULT_FILE_EXCLUDE_PATTERNS ,
95- recursive_subfolders = False ,
96- image_quality_in_editor = None ,
87+ self ,
88+ project : str ,
89+ folder : str ,
90+ extensions : str = constances .DEFAULT_IMAGE_EXTENSIONS ,
91+ set_annotation_status : str = constances .AnnotationStatus .NOT_STARTED .name ,
92+ exclude_file_patterns = constances .DEFAULT_FILE_EXCLUDE_PATTERNS ,
93+ recursive_subfolders = False ,
94+ image_quality_in_editor = None ,
9795 ):
9896 """
9997 To upload images from folder to project use:
@@ -117,12 +115,12 @@ def upload_images(
117115 sys .exit (0 )
118116
119117 def export_project (
120- self ,
121- project ,
122- folder ,
123- include_fuse = False ,
124- disable_extract_zip_contents = False ,
125- annotation_statuses = None ,
118+ self ,
119+ project ,
120+ folder ,
121+ include_fuse = False ,
122+ disable_extract_zip_contents = False ,
123+ annotation_statuses = None ,
126124 ):
127125 project_name , folder_name = split_project_path (project )
128126 folders = None
@@ -148,7 +146,7 @@ def export_project(
148146 sys .exit (0 )
149147
150148 def upload_annotations (
151- self , project , folder , dataset_name = None , task = None , format = None
149+ self , project , folder , dataset_name = None , task = None , format = None
152150 ):
153151 """
154152 To upload annotations from folder to project use
@@ -198,10 +196,10 @@ def _upload_annotations(self, project, folder, format, dataset_name, task):
198196 sys .exit (0 )
199197
200198 def attach_image_urls (
201- self ,
202- project : str ,
203- attachments : str ,
204- annotation_status : Optional [Any ] = "NotStarted" ,
199+ self ,
200+ project : str ,
201+ attachments : str ,
202+ annotation_status : Optional [Any ] = "NotStarted" ,
205203 ):
206204 """
207205 To attach image URLs to project use:
@@ -215,10 +213,10 @@ def attach_image_urls(
215213 sys .exit (0 )
216214
217215 def attach_video_urls (
218- self ,
219- project : str ,
220- attachments : str ,
221- annotation_status : Optional [Any ] = "NotStarted" ,
216+ self ,
217+ project : str ,
218+ attachments : str ,
219+ annotation_status : Optional [Any ] = "NotStarted" ,
222220 ):
223221 SAClient ().attach_items (
224222 project = project ,
@@ -229,7 +227,7 @@ def attach_video_urls(
229227
230228 @staticmethod
231229 def attach_document_urls (
232- project : str , attachments : str , annotation_status : Optional [Any ] = "NotStarted"
230+ project : str , attachments : str , annotation_status : Optional [Any ] = "NotStarted"
233231 ):
234232 SAClient ().attach_items (
235233 project = project ,
@@ -239,15 +237,15 @@ def attach_document_urls(
239237 sys .exit (0 )
240238
241239 def upload_videos (
242- self ,
243- project ,
244- folder ,
245- target_fps = None ,
246- recursive = False ,
247- extensions = constances .DEFAULT_VIDEO_EXTENSIONS ,
248- set_annotation_status = constances .AnnotationStatus .NOT_STARTED .name ,
249- start_time = 0.0 ,
250- end_time = None ,
240+ self ,
241+ project ,
242+ folder ,
243+ target_fps = None ,
244+ recursive = False ,
245+ extensions = constances .DEFAULT_VIDEO_EXTENSIONS ,
246+ set_annotation_status = constances .AnnotationStatus .NOT_STARTED .name ,
247+ start_time = 0.0 ,
248+ end_time = None ,
251249 ):
252250 """
253251 To upload videos from folder to project use
@@ -273,20 +271,3 @@ def upload_videos(
273271 image_quality_in_editor = None ,
274272 )
275273 sys .exit (0 )
276-
277- def create_server (self , name : str , path : str = None ):
278- """
279- This will create a directory by the given name in your current or provided directory.
280- """
281- path = Path (os .path .expanduser (path if path else "." )) / name
282- if path .exists ():
283- raise Exception (f"Directory already exists { str (path .absolute ())} " )
284- path .mkdir (parents = True )
285- default_files_path = Path (sa_lib .__file__ ).parent / "app" / "server"
286- shutil .copy (default_files_path / "__app.py" , path / "app.py" )
287- shutil .copy (default_files_path / "__wsgi.py" , path / "wsgi.py" )
288- shutil .copy (default_files_path / "Dockerfile" , path / "Dockerfile" )
289- shutil .copy (default_files_path / "requirements.txt" , path / "requirements.txt" )
290- shutil .copy (default_files_path / "README.rst" , path / "README.rst" )
291- shutil .copy (default_files_path / "run.sh" , path / "run.sh" )
292- shutil .copytree (default_files_path / "deployment" , path / "deployment" )
0 commit comments