Spaces:
Running
Running
Rename variable containing path to snapshot
Browse files
server.py
CHANGED
|
@@ -149,7 +149,7 @@ class LeaderboardServer:
|
|
| 149 |
def __init__(self):
|
| 150 |
self.SERVER_ADDRESS = REPO
|
| 151 |
self.REPO_TYPE = "dataset"
|
| 152 |
-
self.
|
| 153 |
self.SERVER_ADDRESS,
|
| 154 |
repo_type=self.REPO_TYPE,
|
| 155 |
token=HF_TOKEN,
|
|
@@ -174,7 +174,7 @@ class LeaderboardServer:
|
|
| 174 |
self.results_dataset_integrity_check() # Check integrity of the results dataset after (re)start Hugging Face Space
|
| 175 |
|
| 176 |
def update_leaderboard(self):
|
| 177 |
-
self.
|
| 178 |
self.SERVER_ADDRESS,
|
| 179 |
repo_type=self.REPO_TYPE,
|
| 180 |
token=HF_TOKEN,
|
|
@@ -187,7 +187,7 @@ class LeaderboardServer:
|
|
| 187 |
self.tournament_results = tournament_results
|
| 188 |
|
| 189 |
def load_tournament_results(self):
|
| 190 |
-
metadata_rank_paths = os.path.join(self.
|
| 191 |
if not os.path.exists(metadata_rank_paths):
|
| 192 |
return {}
|
| 193 |
with open(metadata_rank_paths) as ranks_file:
|
|
@@ -224,7 +224,7 @@ class LeaderboardServer:
|
|
| 224 |
|
| 225 |
def fetch_existing_models(self):
|
| 226 |
# Models data
|
| 227 |
-
for submission_file in glob.glob(os.path.join(self.
|
| 228 |
data = json.load(open(submission_file))
|
| 229 |
metadata = data.get('metadata')
|
| 230 |
if metadata is None:
|
|
@@ -623,7 +623,7 @@ class LeaderboardServer:
|
|
| 623 |
|
| 624 |
def _upload_tournament_results(self, tournament_results):
|
| 625 |
# Temporary save tournament results
|
| 626 |
-
tournament_results_path = os.path.join(self.
|
| 627 |
with open(tournament_results_path, "w") as f:
|
| 628 |
json.dump(tournament_results, f, sort_keys=True, indent=2) # readable JSON
|
| 629 |
|
|
|
|
| 149 |
def __init__(self):
|
| 150 |
self.SERVER_ADDRESS = REPO
|
| 151 |
self.REPO_TYPE = "dataset"
|
| 152 |
+
self.results_dataset_local_snapshot = snapshot_download(
|
| 153 |
self.SERVER_ADDRESS,
|
| 154 |
repo_type=self.REPO_TYPE,
|
| 155 |
token=HF_TOKEN,
|
|
|
|
| 174 |
self.results_dataset_integrity_check() # Check integrity of the results dataset after (re)start Hugging Face Space
|
| 175 |
|
| 176 |
def update_leaderboard(self):
|
| 177 |
+
self.results_dataset_local_snapshot = snapshot_download(
|
| 178 |
self.SERVER_ADDRESS,
|
| 179 |
repo_type=self.REPO_TYPE,
|
| 180 |
token=HF_TOKEN,
|
|
|
|
| 187 |
self.tournament_results = tournament_results
|
| 188 |
|
| 189 |
def load_tournament_results(self):
|
| 190 |
+
metadata_rank_paths = os.path.join(self.results_dataset_local_snapshot, "tournament.json")
|
| 191 |
if not os.path.exists(metadata_rank_paths):
|
| 192 |
return {}
|
| 193 |
with open(metadata_rank_paths) as ranks_file:
|
|
|
|
| 224 |
|
| 225 |
def fetch_existing_models(self):
|
| 226 |
# Models data
|
| 227 |
+
for submission_file in glob.glob(os.path.join(self.results_dataset_local_snapshot, "data") + "/*.json"):
|
| 228 |
data = json.load(open(submission_file))
|
| 229 |
metadata = data.get('metadata')
|
| 230 |
if metadata is None:
|
|
|
|
| 623 |
|
| 624 |
def _upload_tournament_results(self, tournament_results):
|
| 625 |
# Temporary save tournament results
|
| 626 |
+
tournament_results_path = os.path.join(self.results_dataset_local_snapshot, "tournament.json")
|
| 627 |
with open(tournament_results_path, "w") as f:
|
| 628 |
json.dump(tournament_results, f, sort_keys=True, indent=2) # readable JSON
|
| 629 |
|