6161_TaskIdToHoneypotsMapping = dict [int , _HoneypotFrameToValFrame ]
6262_TaskIdToFrameNames = dict [int , list [str ]]
6363
64+
6465@dataclass
6566class _ValidationResult :
6667 job_results : _JobResults
@@ -346,9 +347,7 @@ def validate(self) -> _ValidationResult:
346347 gt_stats = self ._require_field (self ._gt_stats ),
347348 task_id_to_val_layout = self ._require_field (self ._task_id_to_val_layout ),
348349 task_id_to_honeypots_mapping = self ._require_field (self ._task_id_to_honeypots_mapping ),
349- task_id_to_frame_names = self ._require_field (
350- self ._task_id_to_sequence_of_frame_names
351- ),
350+ task_id_to_frame_names = self ._require_field (self ._task_id_to_sequence_of_frame_names ),
352351 )
353352
354353
@@ -433,16 +432,16 @@ def process_intermediate_results( # noqa: PLR0912
433432 for rejected_job_id in rejected_job_ids :
434433 job_frame_range = job_id_to_frame_range [rejected_job_id ]
435434 cvat_task_id = job_id_to_task_id [rejected_job_id ]
436- task_honeypots_mapping = validation_result .task_id_to_honeypots_mapping [cvat_task_id ]
435+ task_honeypots_mapping = validation_result .task_id_to_honeypots_mapping [
436+ cvat_task_id
437+ ]
437438 job_honeypots = sorted (set (task_honeypots_mapping .keys ()) & set (job_frame_range ))
438439 validation_frames = [
439440 val_frame
440441 for honeypot , val_frame in task_honeypots_mapping .items ()
441442 if honeypot in job_honeypots
442443 ]
443- sorted_task_frame_names = validation_result .task_id_to_frame_names [
444- cvat_task_id
445- ]
444+ sorted_task_frame_names = validation_result .task_id_to_frame_names [cvat_task_id ]
446445
447446 for val_frame in validation_frames :
448447 val_frame_name = sorted_task_frame_names [val_frame ]
@@ -486,17 +485,9 @@ def process_intermediate_results( # noqa: PLR0912
486485 )
487486 break
488487
489- task_updated_honeypot_real_frames = task_validation_layout .honeypot_real_frames .copy ()
490-
491- # validation frames may be repeated in the task
492- task_honeypot_to_position : dict [int , list [int ]] = {
493- (honeypot , validation_frame )
494- for (honeypot , validation_frame ) in zip (
495- task_validation_layout .validation_frames ,
496- task_updated_honeypot_real_frames ,
497- strict = True
498- )
499- } # honeypot -> list index
488+ task_honeypot_to_index : dict [int , int ] = {
489+ honeypot : i for i , honeypot in enumerate (task_validation_layout .validation_frames )
490+ } # honeypot -> list index
500491
501492 task_honeypots_mapping = validation_result .task_id_to_honeypots_mapping [cvat_task_id ]
502493
@@ -506,6 +497,7 @@ def process_intermediate_results( # noqa: PLR0912
506497 if j .job_id in rejected_job_ids and j .task_id == cvat_task_id
507498 ]
508499
500+ task_updated_honeypot_real_frames = task_validation_layout .honeypot_real_frames .copy ()
509501 for job in task_rejected_jobs :
510502 job_frame_range = job .job_frame_range
511503 job_honeypots = sorted (set (task_honeypots_mapping .keys ()) & set (job_frame_range ))
@@ -522,7 +514,9 @@ def process_intermediate_results( # noqa: PLR0912
522514 job_validation_frames_to_keep .append (validation_frame )
523515
524516 # choose new unique validation frames for the job
525- assert not (set (job_validation_frames_to_replace ) & set (task_good_validation_frames ))
517+ assert not (
518+ set (job_validation_frames_to_replace ) & set (task_good_validation_frames )
519+ )
526520 job_available_validation_frames = list (
527521 set (task_good_validation_frames ) - set (job_validation_frames_to_keep )
528522 )
@@ -537,14 +531,16 @@ def process_intermediate_results( # noqa: PLR0912
537531 for honeypot , new_validation_frame in zip (
538532 job_validation_frames_to_replace , new_job_validation_frames , strict = True
539533 ):
540- honeypot_index = task_honeypot_to_position [honeypot ]
534+ honeypot_index = task_honeypot_to_index [honeypot ]
541535 task_updated_honeypot_real_frames [honeypot_index ] = new_validation_frame
542536
543537 # Make sure honeypots do not repeat in jobs
544- assert len (set (
545- task_updated_honeypot_real_frames [task_honeypot_to_position [honeypot ]]
546- for honeypot in job_honeypots
547- )) == len (job_honeypots )
538+ assert len (
539+ {
540+ task_updated_honeypot_real_frames [task_honeypot_to_index [honeypot ]]
541+ for honeypot in job_honeypots
542+ }
543+ ) == len (job_honeypots )
548544
549545 cvat_api .update_task_validation_layout (
550546 cvat_task_id ,
0 commit comments