@@ -1078,3 +1078,40 @@ def create_fuse_image(
10781078 return (fuse_path , overlay_path )
10791079 else :
10801080 return (fuse_path , )
1081+
1082+
1083+ def set_images_annotation_statuses (project , image_names , annotation_status ):
1084+ """Sets annotation statuses of images
1085+
1086+ :param project: project name or folder path (e.g., "project1/folder1")
1087+ :type project: str
1088+ :param image_names: image names. If None, all the images in the project will be used
1089+ :type image_names: list of str
1090+ :param annotation_status: annotation status to set,
1091+ should be one of NotStarted InProgress QualityCheck Returned Completed Skipped
1092+ :type annotation_status: str
1093+ """
1094+ NUM_TO_SEND = 500
1095+ project , project_folder = get_project_and_folder_metadata (project )
1096+ params = {"team_id" : project ["team_id" ], "project_id" : project ["id" ]}
1097+ annotation_status = common .annotation_status_str_to_int (annotation_status )
1098+ data = {
1099+ "annotation_status" : annotation_status ,
1100+ "folder_id" : project_folder ["id" ]
1101+ }
1102+ if image_names is None :
1103+ image_names = search_images (project )
1104+ for start_index in range (0 , len (image_names ), NUM_TO_SEND ):
1105+ data ["image_names" ] = image_names [start_index :start_index + NUM_TO_SEND ]
1106+ response = _api .send_request (
1107+ req_type = 'PUT' ,
1108+ path = f'/image/updateAnnotationStatusBulk' ,
1109+ params = params ,
1110+ json_req = data
1111+ )
1112+ if not response .ok :
1113+ raise SABaseException (
1114+ response .status_code ,
1115+ "Couldn't change annotation statuses " + response .text
1116+ )
1117+ logger .info ("Annotations status of images changed" )
0 commit comments