@@ -370,3 +370,69 @@ def test_nested_video_object_annotations(client,
370370 import_annotations .wait_until_done ()
371371
372372 assert import_annotations .errors == []
373+
374+
375+ def test_below_annotation_limit_on_single_data_row (
376+ client , configured_project_with_one_data_row , video_data , rand_gen ):
377+ _ , data_row_uids = video_data
378+
379+ def create_label ():
380+ return Label (data = VideoData (uid = data_row_uids [0 ]),
381+ annotations = [
382+ VideoObjectAnnotation (name = "bbox" ,
383+ keyframe = True ,
384+ frame = 4 ,
385+ segment_index = 0 ,
386+ value = Rectangle (
387+ start = Point (x = 100 , y = 100 ),
388+ end = Point (x = 105 , y = 105 ),
389+ ))
390+ ])
391+
392+ configured_project_with_one_data_row .update (media_type = MediaType .Video )
393+ configured_project_with_one_data_row .create_batch (
394+ rand_gen (str ),
395+ data_row_uids , # sample of data row objects
396+ 5 # priority between 1(Highest) - 5(lowest)
397+ )
398+ labels = [create_label () for _ in range (5000 )]
399+ import_annotations = MALPredictionImport .create_from_objects (
400+ client = client ,
401+ project_id = configured_project_with_one_data_row .uid ,
402+ name = f"import { str (uuid .uuid4 ())} " ,
403+ predictions = labels )
404+ import_annotations .wait_until_done ()
405+
406+ assert import_annotations .errors == []
407+
408+
409+ def test_above_annotation_limit_on_single_data_row (
410+ client , configured_project_with_one_data_row , video_data , rand_gen ):
411+ _ , data_row_uids = video_data
412+
413+ def create_label ():
414+ return Label (data = VideoData (uid = data_row_uids [0 ]),
415+ annotations = [
416+ VideoObjectAnnotation (name = "bbox" ,
417+ keyframe = True ,
418+ frame = 4 ,
419+ segment_index = 0 ,
420+ value = Rectangle (
421+ start = Point (x = 100 , y = 100 ),
422+ end = Point (x = 105 , y = 105 ),
423+ ))
424+ ])
425+
426+ configured_project_with_one_data_row .update (media_type = MediaType .Video )
427+ configured_project_with_one_data_row .create_batch (
428+ rand_gen (str ),
429+ data_row_uids , # sample of data row objects
430+ 5 # priority between 1(Highest) - 5(lowest)
431+ )
432+ labels = [create_label () for _ in range (5001 )]
433+ with pytest .raises (ValueError ):
434+ MALPredictionImport .create_from_objects (
435+ client = client ,
436+ project_id = configured_project_with_one_data_row .uid ,
437+ name = f"import { str (uuid .uuid4 ())} " ,
438+ predictions = labels )
0 commit comments