Spaces:
Runtime error
Runtime error
| 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) | |