idolezal commited on
Commit
dfdc202
·
1 Parent(s): 8ae0f62

Now only executes the duels that are missing

Browse files

The `LeaderboardServer.start_tournament()` method only executes the duels that are missing

The `LeaderboardServer.results_dataset_integrity_check()` method only removes extra duels or performs missing duels as part of inconsistency resolution

Files changed (1) hide show
  1. server.py +29 -11
server.py CHANGED
@@ -406,6 +406,7 @@ class LeaderboardServer:
406
  -- pokud ne, znemožní potvrzení nových submitů a udělá zbývající zápasy
407
  -- kontroluje soubory v adresáři "/data" a soubor "tournament.json"
408
  - v souboru "tournament.json" není `submission_id`, které by nemělo soubor v adresáři "/data"
 
409
  """
410
 
411
  while True:
@@ -447,19 +448,34 @@ class LeaderboardServer:
447
  gr.Info('Running tournament...', duration=15)
448
 
449
  with self.var_lock.rw:
450
- self.tournament_results = {}
451
- submission_ids_backup = self.submission_ids
452
- self.submission_ids = set()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
453
 
454
- for i, submission_id in enumerate(submission_ids_backup):
455
- self.tournament_results_integrity_solving_progress = i / len(submission_ids_backup)
456
 
457
  with self.var_lock.ro:
458
  file = self.submission_id_to_file[submission_id]
459
  tournament_results = self.start_tournament(submission_id, file)
460
  with self.var_lock.rw:
461
  self.tournament_results = tournament_results
462
- self.submission_ids.add(submission_id)
463
 
464
  self.tournament_results_integrity_solving_progress = 1
465
 
@@ -749,12 +765,14 @@ class LeaderboardServer:
749
  def start_tournament(self, new_submission_id, new_model_file):
750
  with self.var_lock.ro:
751
  new_tournament = copy.deepcopy(self.tournament_results)
752
- new_tournament[new_submission_id] = {}
753
- new_tournament[new_submission_id][new_submission_id] = {
754
- task: False for task in self.TASKS_METADATA.keys()
755
- }
 
756
 
757
- rest_of_competitors = list(self.submission_ids - {new_submission_id}) # without self
 
758
  num_of_competitors = len(rest_of_competitors)
759
 
760
  result_url = {}
 
406
  -- pokud ne, znemožní potvrzení nových submitů a udělá zbývající zápasy
407
  -- kontroluje soubory v adresáři "/data" a soubor "tournament.json"
408
  - v souboru "tournament.json" není `submission_id`, které by nemělo soubor v adresáři "/data"
409
+ - negeneruje soubor "tournament.json" celý znovu, ale pouze dopočítá co chybí
410
  """
411
 
412
  while True:
 
448
  gr.Info('Running tournament...', duration=15)
449
 
450
  with self.var_lock.rw:
451
+ submission_ids_for_renew_tournament = set()
452
+
453
+ submission_ids_not_known = self.tournament_results.keys() - self.submission_ids
454
+ submission_ids_not_in_tournament = self.submission_ids - self.tournament_results.keys()
455
+
456
+ submission_ids_for_renew_tournament |= submission_ids_not_in_tournament
457
+
458
+ for submission_id in submission_ids_not_known:
459
+ self.tournament_results.pop(submission_id)
460
+
461
+ for submission_id in self.submission_ids:
462
+ competitor_ids_not_known = self.tournament_results[submission_id].keys() - self.submission_ids
463
+ competitor_ids_not_in_tournament = self.submission_ids - self.tournament_results[submission_id].keys()
464
+
465
+ for competitor_id in competitor_ids_not_known:
466
+ self.tournament_results[submission_id].pop(competitor_id)
467
+
468
+ if competitor_ids_not_in_tournament:
469
+ submission_ids_for_renew_tournament.add(submission_id)
470
 
471
+ for i, submission_id in enumerate(submission_ids_for_renew_tournament):
472
+ self.tournament_results_integrity_solving_progress = i / len(submission_ids_for_renew_tournament)
473
 
474
  with self.var_lock.ro:
475
  file = self.submission_id_to_file[submission_id]
476
  tournament_results = self.start_tournament(submission_id, file)
477
  with self.var_lock.rw:
478
  self.tournament_results = tournament_results
 
479
 
480
  self.tournament_results_integrity_solving_progress = 1
481
 
 
765
  def start_tournament(self, new_submission_id, new_model_file):
766
  with self.var_lock.ro:
767
  new_tournament = copy.deepcopy(self.tournament_results)
768
+ if new_submission_id not in new_tournament:
769
+ new_tournament[new_submission_id] = {}
770
+ new_tournament[new_submission_id][new_submission_id] = {
771
+ task: False for task in self.TASKS_METADATA.keys()
772
+ }
773
 
774
+ competitor_ids_in_tournament = new_tournament[new_submission_id].keys()
775
+ rest_of_competitors = list(self.submission_ids - {new_submission_id} - competitor_ids_in_tournament) # without self and without the opponents with which it has already contended
776
  num_of_competitors = len(rest_of_competitors)
777
 
778
  result_url = {}