Spaces:
Running
Running
Update src/saving_utils.py
Browse files- src/saving_utils.py +20 -0
src/saving_utils.py
CHANGED
|
@@ -6,6 +6,26 @@ from huggingface_hub import HfApi
|
|
| 6 |
script_dir = os.path.dirname(os.path.abspath(__file__)) # Directory of the running script
|
| 7 |
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def download_files_from_hub(benchmark_types, repo_id="mgyigit/probe-data", repo_type="space"):
|
| 11 |
api = HfApi(token=os.getenv("api-key")) #load api-key secret
|
|
|
|
| 6 |
script_dir = os.path.dirname(os.path.abspath(__file__)) # Directory of the running script
|
| 7 |
|
| 8 |
|
| 9 |
+
def save_results(method_name, benchmark_types, results, repo_id="mgiyigt/probe-data", repo_type="space"):
|
| 10 |
+
#First, download files to be updated from {repo_id}
|
| 11 |
+
download_files_from_hub(benchmark_types, repo_id, repo_type)
|
| 12 |
+
|
| 13 |
+
#Update local files
|
| 14 |
+
for benchmark_type in benchmark_types:
|
| 15 |
+
if benchmark_type == 'similarity':
|
| 16 |
+
save_similarity_output(results['similarity'], method_name)
|
| 17 |
+
elif benchmark_type == 'function':
|
| 18 |
+
save_function_output(results['function'], method_name)
|
| 19 |
+
elif benchmark_type == 'family':
|
| 20 |
+
save_family_output(results['family'], method_name)
|
| 21 |
+
elif benchmark_type == "affinity":
|
| 22 |
+
save_affinity_output(results['affinity', method_name])
|
| 23 |
+
|
| 24 |
+
#Upload local files to the {repo_id}
|
| 25 |
+
upload_to_hub(benchmark_types, repo_id, repo_type)
|
| 26 |
+
|
| 27 |
+
return 0
|
| 28 |
+
|
| 29 |
|
| 30 |
def download_files_from_hub(benchmark_types, repo_id="mgyigit/probe-data", repo_type="space"):
|
| 31 |
api = HfApi(token=os.getenv("api-key")) #load api-key secret
|