Spaces:
Running
Running
For testing purpose improved fake tournament
Browse files
app.py
CHANGED
|
@@ -22,7 +22,6 @@ HF_SPACE_TOKEN = os.environ["HF_SPACE_TOKEN"]
|
|
| 22 |
HF_SPACE_ID = os.environ["HF_SPACE_ID"]
|
| 23 |
# For testing purpose
|
| 24 |
HF_DISABLE_SUBMIT = bool(int(os.environ.get("HF_DISABLE_SUBMIT", "0")))
|
| 25 |
-
from server import HF_FAKE_TOURNAMENT
|
| 26 |
|
| 27 |
from huggingface_hub import dump_environment_info
|
| 28 |
dump_environment_info()
|
|
@@ -97,8 +96,6 @@ def process_submission(*inputs):
|
|
| 97 |
gr.Info('Submission valid, going to queue for the tournament…')
|
| 98 |
|
| 99 |
pre_submit = leaderboard_server.prepare_model_for_submission(inputs["submission_file"], metadata)
|
| 100 |
-
if HF_FAKE_TOURNAMENT:
|
| 101 |
-
pre_submit = None
|
| 102 |
except ValueError as err:
|
| 103 |
gr.Warning(str(err))
|
| 104 |
return (
|
|
|
|
| 22 |
HF_SPACE_ID = os.environ["HF_SPACE_ID"]
|
| 23 |
# For testing purpose
|
| 24 |
HF_DISABLE_SUBMIT = bool(int(os.environ.get("HF_DISABLE_SUBMIT", "0")))
|
|
|
|
| 25 |
|
| 26 |
from huggingface_hub import dump_environment_info
|
| 27 |
dump_environment_info()
|
|
|
|
| 96 |
gr.Info('Submission valid, going to queue for the tournament…')
|
| 97 |
|
| 98 |
pre_submit = leaderboard_server.prepare_model_for_submission(inputs["submission_file"], metadata)
|
|
|
|
|
|
|
| 99 |
except ValueError as err:
|
| 100 |
gr.Warning(str(err))
|
| 101 |
return (
|
server.py
CHANGED
|
@@ -773,6 +773,39 @@ class LeaderboardServer:
|
|
| 773 |
)
|
| 774 |
return dataframe
|
| 775 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 776 |
def start_tournament(self, new_submission_id, new_model_file):
|
| 777 |
with self.var_lock.ro:
|
| 778 |
new_tournament = copy.deepcopy(self.tournament_results)
|
|
@@ -786,7 +819,12 @@ class LeaderboardServer:
|
|
| 786 |
if new_submission_id not in new_tournament:
|
| 787 |
new_tournament[new_submission_id] = {}
|
| 788 |
new_tournament[new_submission_id][new_submission_id] = {
|
| 789 |
-
task:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 790 |
}
|
| 791 |
|
| 792 |
competitor_ids_in_tournament = new_tournament[new_submission_id].keys()
|
|
@@ -908,11 +946,12 @@ class LeaderboardServer:
|
|
| 908 |
print(info_msg)
|
| 909 |
|
| 910 |
self.update_leaderboard()
|
|
|
|
| 911 |
if HF_FAKE_TOURNAMENT:
|
| 912 |
-
|
| 913 |
-
tournament_results = copy.deepcopy(self.tournament_results)
|
| 914 |
else:
|
| 915 |
tournament_results = self.start_tournament(submission_id, file)
|
|
|
|
| 916 |
pre_submit = self.PreSubmit(
|
| 917 |
tournament_results,
|
| 918 |
submission_id,
|
|
|
|
| 773 |
)
|
| 774 |
return dataframe
|
| 775 |
|
| 776 |
+
def fake_tournament(self, new_submission_id, new_model_file):
|
| 777 |
+
DRAW_MATCH = {
|
| 778 |
+
task: {
|
| 779 |
+
"significant": False,
|
| 780 |
+
"p_value": 0.5,
|
| 781 |
+
"delta": 0.0,
|
| 782 |
+
"fake": True,
|
| 783 |
+
}
|
| 784 |
+
for task in self.TASKS_METADATA.keys()
|
| 785 |
+
}
|
| 786 |
+
|
| 787 |
+
with self.var_lock.ro:
|
| 788 |
+
new_tournament = copy.deepcopy(self.tournament_results)
|
| 789 |
+
|
| 790 |
+
pre_submit = self.pre_submit.get(new_submission_id)
|
| 791 |
+
if pre_submit:
|
| 792 |
+
new_tournament[new_submission_id] = pre_submit.tournament_results[new_submission_id]
|
| 793 |
+
for competitor_id in pre_submit.tournament_results[new_submission_id].keys() - {new_submission_id}:
|
| 794 |
+
new_tournament[competitor_id][new_submission_id] = pre_submit.tournament_results[competitor_id][new_submission_id]
|
| 795 |
+
|
| 796 |
+
if new_submission_id not in new_tournament:
|
| 797 |
+
new_tournament[new_submission_id] = {}
|
| 798 |
+
new_tournament[new_submission_id][new_submission_id] = copy.deepcopy(DRAW_MATCH)
|
| 799 |
+
|
| 800 |
+
competitor_ids_in_tournament = new_tournament[new_submission_id].keys()
|
| 801 |
+
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
|
| 802 |
+
|
| 803 |
+
for competitor_id in rest_of_competitors:
|
| 804 |
+
new_tournament[new_submission_id][competitor_id] = copy.deepcopy(DRAW_MATCH)
|
| 805 |
+
new_tournament[competitor_id][new_submission_id] = copy.deepcopy(DRAW_MATCH)
|
| 806 |
+
|
| 807 |
+
return new_tournament
|
| 808 |
+
|
| 809 |
def start_tournament(self, new_submission_id, new_model_file):
|
| 810 |
with self.var_lock.ro:
|
| 811 |
new_tournament = copy.deepcopy(self.tournament_results)
|
|
|
|
| 819 |
if new_submission_id not in new_tournament:
|
| 820 |
new_tournament[new_submission_id] = {}
|
| 821 |
new_tournament[new_submission_id][new_submission_id] = {
|
| 822 |
+
task: {
|
| 823 |
+
"significant": False,
|
| 824 |
+
"p_value": 0.5,
|
| 825 |
+
"delta": 0.0,
|
| 826 |
+
}
|
| 827 |
+
for task in self.TASKS_METADATA.keys()
|
| 828 |
}
|
| 829 |
|
| 830 |
competitor_ids_in_tournament = new_tournament[new_submission_id].keys()
|
|
|
|
| 946 |
print(info_msg)
|
| 947 |
|
| 948 |
self.update_leaderboard()
|
| 949 |
+
|
| 950 |
if HF_FAKE_TOURNAMENT:
|
| 951 |
+
tournament_results = self.fake_tournament(submission_id, file)
|
|
|
|
| 952 |
else:
|
| 953 |
tournament_results = self.start_tournament(submission_id, file)
|
| 954 |
+
|
| 955 |
pre_submit = self.PreSubmit(
|
| 956 |
tournament_results,
|
| 957 |
submission_id,
|