Spaces:
Runtime error
Runtime error
File size: 742 Bytes
1a881d8 55ece2a 1a881d8 55ece2a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import json
import os
def already_submitted_models(requested_models_dir: str) -> set[str]:
"""Gather a list of already submitted models to avoid duplicates"""
depth = 1
file_names = []
for root, _, files in os.walk(requested_models_dir):
current_depth = root.count(os.sep) - requested_models_dir.count(os.sep)
if current_depth == depth:
for file in files:
if not file.endswith(".json"):
continue
with open(os.path.join(root, file), "r") as f:
info = json.load(f)
file_names.append(f"{info['model_name']}_{info['training_dataset']}_{info['testing_type']}_{info['precision']}")
return set(file_names)
|