@@ -43,64 +43,67 @@ def test_benchmark(self):
4343 "folderName" ,
4444 "score" ,
4545 ]
46- export_path = self .export_path
47- for i in range (1 , 4 ):
48- sa .create_folder (self .PROJECT_NAME , self .CONSENSUS_PREFIX + str (i ))
49- sa .create_annotation_classes_from_classes_json (
50- self .PROJECT_NAME , self .export_path + "/classes/classes.json"
51- )
52- sa .upload_images_from_folder_to_project (
53- self .PROJECT_NAME ,
54- self .export_path + "/images" ,
55- annotation_status = "Completed" ,
56- )
57- for i in range (1 , 4 ):
46+
47+ with tempfile .TemporaryDirectory () as tmpdir :
48+ temp_export_path = str (tmpdir )
49+
50+ for i in range (1 , 4 ):
51+ sa .create_folder (self .PROJECT_NAME , self .CONSENSUS_PREFIX + str (i ))
52+ sa .create_annotation_classes_from_classes_json (
53+ self .PROJECT_NAME , self .export_path + "/classes/classes.json"
54+ )
5855 sa .upload_images_from_folder_to_project (
59- self .PROJECT_NAME + f"/ { self . CONSENSUS_PREFIX } " + str ( i ) ,
56+ self .PROJECT_NAME ,
6057 self .export_path + "/images" ,
6158 annotation_status = "Completed" ,
6259 )
63- time .sleep (2 )
64- sa .upload_annotations_from_folder_to_project (
65- self .PROJECT_NAME , self .export_path
66- )
67- for i in range (1 , 4 ):
60+ for i in range (1 , 4 ):
61+ sa .upload_images_from_folder_to_project (
62+ self .PROJECT_NAME + f"/{ self .CONSENSUS_PREFIX } " + str (i ),
63+ self .export_path + "/images" ,
64+ annotation_status = "Completed" ,
65+ )
66+ time .sleep (2 )
6867 sa .upload_annotations_from_folder_to_project (
69- self .PROJECT_NAME + f"/{ self .CONSENSUS_PREFIX } " + str (i ),
70- self .export_path + f"/{ self .CONSENSUS_PREFIX } " + str (i ),
68+ self .PROJECT_NAME , self .export_path
7169 )
70+ for i in range (1 , 4 ):
71+ sa .upload_annotations_from_folder_to_project (
72+ self .PROJECT_NAME + f"/{ self .CONSENSUS_PREFIX } " + str (i ),
73+ self .export_path + f"/{ self .CONSENSUS_PREFIX } " + str (i ),
74+ )
7275
73- for annotation_type in annotation_types :
74- res_df = sa .benchmark (
75- self .PROJECT_NAME ,
76- self .GT_FOLDER_NAME ,
77- folder_names ,
78- annot_type = annotation_type ,
79- )
80- # test content of projectName column
81- assert sorted (res_df ["folderName" ].unique ()) == folder_names
76+ for annotation_type in annotation_types :
77+ res_df = sa .benchmark (
78+ self .PROJECT_NAME ,
79+ self .GT_FOLDER_NAME ,
80+ folder_names ,
81+ annot_type = annotation_type ,
82+ )
83+ # test content of projectName column
84+ assert sorted (res_df ["folderName" ].unique ()) == folder_names
8285
83- # test structure of resulting DataFrame
84- assert sorted (res_df .columns ) == sorted (df_column_names )
86+ # test structure of resulting DataFrame
87+ assert sorted (res_df .columns ) == sorted (df_column_names )
8588
86- # test lower bound of the score
87- assert (res_df ["score" ] >= 0 ).all ()
89+ # test lower bound of the score
90+ assert (res_df ["score" ] >= 0 ).all ()
8891
89- # test upper bound of the score
90- assert (res_df ["score" ] <= 1 ).all ()
92+ # test upper bound of the score
93+ assert (res_df ["score" ] <= 1 ).all ()
9194
92- image_names = [
93- "bonn_000000_000019_leftImg8bit.png" ,
94- "bielefeld_000000_000321_leftImg8bit.png" ,
95- ]
95+ image_names = [
96+ "bonn_000000_000019_leftImg8bit.png" ,
97+ "bielefeld_000000_000321_leftImg8bit.png" ,
98+ ]
9699
97- # test filtering images with given image names list
98- res_images = sa .benchmark (
99- self .PROJECT_NAME ,
100- self .GT_FOLDER_NAME ,
101- folder_names ,
102- export_root = export_path ,
103- image_list = image_names ,
104- )
100+ # test filtering images with given image names list
101+ res_images = sa .benchmark (
102+ self .PROJECT_NAME ,
103+ self .GT_FOLDER_NAME ,
104+ folder_names ,
105+ export_root = temp_export_path ,
106+ image_list = image_names ,
107+ )
105108
106- assert sorted (res_images ["imageName" ].unique ()) == sorted (image_names )
109+ assert sorted (res_images ["imageName" ].unique ()) == sorted (image_names )
0 commit comments