@@ -977,7 +977,7 @@ def get_image_metadata(project, image_name, *_, **__):
977977 raise AppValidationException (response .errors )
978978
979979 res_data = response .data
980- res_data . data ["annotation_status" ] = constances .AnnotationStatus .get_name (
980+ res_data ["annotation_status" ] = constances .AnnotationStatus .get_name (
981981 res_data ["annotation_status" ]
982982 )
983983 return res_data
@@ -2389,7 +2389,48 @@ def attach_video_urls_to_project(project, attachments, annotation_status="NotSta
23892389 :return: attached videos, failed videos, skipped videos
23902390 :rtype: (list, list, list)
23912391 """
2392- return attach_image_urls_to_project (project , attachments , annotation_status )
2392+ project_name , folder_name = extract_project_folder (project )
2393+ project = controller .get_project_metadata (project_name ).data
2394+ if project ["project" ].project_type != constances .ProjectType .VIDEO .value :
2395+ raise AppValidationException ("The function does not support" )
2396+
2397+ image_data = pd .read_csv (attachments , dtype = str )
2398+ image_data = image_data [~ image_data ["url" ].isnull ()]
2399+ if "name" in image_data .columns :
2400+ image_data ["name" ] = (
2401+ image_data ["name" ]
2402+ .fillna ("" )
2403+ .apply (lambda cell : cell if str (cell ).strip () else str (uuid .uuid4 ()))
2404+ )
2405+ else :
2406+ image_data ["name" ] = [str (uuid .uuid4 ()) for _ in range (len (image_data .index ))]
2407+
2408+ image_data = pd .DataFrame (image_data , columns = ["name" , "url" ])
2409+ img_names_urls = image_data .rename (columns = {"url" : "path" }).to_dict (
2410+ orient = "records"
2411+ )
2412+ list_of_not_uploaded = []
2413+ duplicate_images = []
2414+ for i in range (0 , len (img_names_urls ), 500 ):
2415+ response = controller .attach_urls (
2416+ project_name = project_name ,
2417+ folder_name = folder_name ,
2418+ files = ImageSerializer .deserialize (
2419+ img_names_urls [i : i + 500 ] # noqa: E203
2420+ ),
2421+ annotation_status = annotation_status ,
2422+ )
2423+ if response .errors :
2424+ list_of_not_uploaded .append (response .data [0 ])
2425+ duplicate_images .append (response .data [1 ])
2426+
2427+ list_of_uploaded = [
2428+ image ["name" ]
2429+ for image in img_names_urls
2430+ if image ["name" ] not in list_of_not_uploaded
2431+ ]
2432+
2433+ return list_of_uploaded , list_of_not_uploaded , duplicate_images
23932434
23942435
23952436@Trackable
0 commit comments