@@ -301,6 +301,8 @@ def __validate_and_format_frame_packet_map(
301301 raise Exception ("frame_packet_map is not a dict" )
302302
303303 for frame , instance_list in frame_packet_map .items ():
304+ if instance_list is None :
305+ raise Exception ("instance_list cannot be None" )
304306
305307 if type (frame ) != int :
306308 raise Exception ("frame is not a integer. The key should be the integer frame number." )
@@ -312,7 +314,8 @@ def __validate_and_format_frame_packet_map(
312314 frame_packet_map [frame ] = self .__validate_and_format_instance_list (
313315 instance_list = instance_list ,
314316 assume_new_instances_machine_made = assume_new_instances_machine_made ,
315- convert_names_to_label_files = convert_names_to_label_files
317+ convert_names_to_label_files = convert_names_to_label_files ,
318+ check_frame_number = True
316319 )
317320
318321 return frame_packet_map
@@ -321,7 +324,8 @@ def __validate_and_format_instance_list(
321324 self ,
322325 instance_list : list ,
323326 assume_new_instances_machine_made : bool ,
324- convert_names_to_label_files : bool ):
327+ convert_names_to_label_files : bool ,
328+ check_frame_number : bool = False ):
325329
326330 FileConstructor .sanity_check_instance_list (instance_list )
327331
@@ -334,6 +338,11 @@ def __validate_and_format_instance_list(
334338 instance_list = instance_list
335339 )
336340
341+ if check_frame_number :
342+ for elm in instance_list :
343+ if elm .get ('frame_number' ) is None :
344+ raise Exception ('All instances must have a "frame_number" key.' )
345+
337346 return instance_list
338347
339348 def instance_list_label_strings_to_ids (self , instance_list : list ):
@@ -368,6 +377,10 @@ def sanity_check_instance_list(instance_list: list):
368377 if len (instance_list ) == 0 :
369378 raise Warning ("'instance_list' is empty" )
370379
380+ for elm in instance_list :
381+ if elm is None :
382+ raise Exception ("instance_list elements cannot be None" )
383+
371384 FileConstructor .__check_for_duplicates_on_instance_list (instance_list )
372385
373386 return
0 commit comments