@@ -48,37 +48,35 @@ def ask_token():
4848
4949
5050def main ():
51- available_commands = "Available commands to superannotate CLI are: init version create-project create-folder upload-images upload-videos upload-preannotations upload-annotations export-project"
51+ available_commands = {
52+ "create-project" : create_project ,
53+ "create-folder" : create_folder ,
54+ "upload-images" : image_upload ,
55+ "attach-image-urls" : attach_video_urls ,
56+ "upload-videos" : video_upload ,
57+ "upload-preannotations" : preannotations_upload ,
58+ "upload-annotations" : preannotations_upload ,
59+ "init" : lambda * args , ** kwargs : ask_token (),
60+ "export-project" : export_project ,
61+ "attach-video-urls" : attach_video_urls ,
62+ "version" : lambda * args , ** kwargs : print (f"SuperAnnotate Python SDK version { sa .__version__ } " )
63+ }
5264 if len (sys .argv ) == 1 :
53- raise SABaseException (
54- 0 , "No command given to superannotate CLI. " + available_commands
65+ print (
66+ "No command given to superannotate CLI. Available commands to superannotate CLI are:"
67+ + ", " .join (available_commands .keys ())
5568 )
69+
5670 command = sys .argv [1 ]
5771 further_args = sys .argv [2 :]
58-
59- if command == "create-project" :
60- create_project (command , further_args )
61- elif command == "create-folder" :
62- create_folder (command , further_args )
63- elif command == "upload-images" :
64- image_upload (command , further_args )
65- elif command == "attach-image-urls" :
66- attach_image_urls (command , further_args )
67- elif command == "upload-videos" :
68- video_upload (command , further_args )
69- elif command in ["upload-preannotations" , "upload-annotations" ]:
70- preannotations_upload (command , further_args )
71- elif command == "init" :
72- ask_token ()
73- elif command == "export-project" :
74- export_project (command , further_args )
75- elif command == "version" :
76- print (f"SuperAnnotate Python SDK version { sa .__version__ } " )
77- else :
78- raise SABaseException (
79- 0 , "Wrong command " + command + " to superannotate CLI. " +
80- available_commands
81- )
72+ try :
73+ available_commands [command ](command , further_args )
74+ except KeyError :
75+ sys .stdout .write ("Wrong command " + command + " to superannotate CLI. " + ", " .join (available_commands .keys ()))
76+ except SABaseException as e :
77+ sys .stdout .write (e .message )
78+ except BaseException as e :
79+ sys .stdout .write (str (e ))
8280
8381
8482def _list_str (values ):
@@ -364,5 +362,30 @@ def export_project(command_name, args):
364362 )
365363
366364
365+ def attach_video_urls (command_name , args ):
366+ parser = argparse .ArgumentParser (prog = _CLI_COMMAND + " " + command_name )
367+ parser .add_argument (
368+ '--project' , required = True , help = 'Project name to upload'
369+ )
370+ parser .add_argument (
371+ '--attachments' ,
372+ required = True ,
373+ help = 'path to csv file on attachments metadata'
374+ )
375+ parser .add_argument (
376+ '--annotation_status' ,
377+ required = False ,
378+ default = "NotStarted" ,
379+ help =
380+ 'Set images\' annotation statuses after upload. Default is NotStarted'
381+ )
382+ args = parser .parse_args (args )
383+ sa .attach_video_urls_to_project (
384+ project = args .project ,
385+ attachments = args .attachments ,
386+ annotation_status = args .annotation_status
387+ )
388+
389+
367390if __name__ == "__main__" :
368391 main ()
0 commit comments