Weyaxi commited on
Commit
42ebf2f
1 Parent(s): 804fada

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -5
app.py CHANGED
@@ -1,4 +1,5 @@
1
  from huggingface_hub import *
 
2
  import json
3
  import gradio as gr
4
 
@@ -45,19 +46,40 @@ def return_operation_results(from_model, to_model):
45
  return liste
46
 
47
 
48
- def commit(liste_requests, liste_results):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  request_commit = (create_commit(repo_id="Weyaxi/requests", operations=liste_requests, commit_message=f"Renaming Models", repo_type="dataset", create_pr=True).__dict__['pr_url'])
50
  result_commit = (create_commit(repo_id="Weyaxi/results", operations=liste_results, commit_message=f"Renaming Models", repo_type="dataset", create_pr=True).__dict__['pr_url'])
51
- return request_commit, result_commit
 
52
 
53
 
54
  def commit_gradio(from_model, to_model, hf_token):
55
  try:
56
  login(hf_token)
57
- return commit(return_operation_requests(from_model, to_model), return_operation_results(from_model, to_model))
58
  except Exception as e:
59
  return e
60
 
61
-
62
  demo = gr.Interface(fn=commit_gradio, inputs=["text", "text", "text"], outputs="text")
63
- demo.launch()
 
 
1
  from huggingface_hub import *
2
+ import os
3
  import json
4
  import gradio as gr
5
 
 
46
  return liste
47
 
48
 
49
+
50
+ def model_name_to_details(model_name):
51
+ return f"datasets/open-llm-leaderboard/details_{model_name.split('/')[0]}__{model_name.split('/')[1]}"
52
+
53
+
54
+ def return_operation_details(from_model, to_model):
55
+ ls = [i['name'] for i in fs.ls(path=model_name_to_details(from_model)) if ("results" in i['name'] and ".json" in i['name'])]
56
+ liste=[]
57
+
58
+ for i in range(len(ls)):
59
+ path_for = ls[i]
60
+
61
+ will_write = json.loads(fs.read_text(path_for))
62
+ will_write['config_general']['model_name'] = to_model
63
+ will_write = json.dumps(will_write, indent=2)
64
+
65
+ liste.extend([CommitOperationAdd(path_in_repo="/".join(path_for.split("/")[3:]), path_or_fileobj=will_write.encode())])
66
+
67
+ return liste
68
+
69
+ def commit(liste_requests, liste_results, liste_details, details_path):
70
  request_commit = (create_commit(repo_id="Weyaxi/requests", operations=liste_requests, commit_message=f"Renaming Models", repo_type="dataset", create_pr=True).__dict__['pr_url'])
71
  result_commit = (create_commit(repo_id="Weyaxi/results", operations=liste_results, commit_message=f"Renaming Models", repo_type="dataset", create_pr=True).__dict__['pr_url'])
72
+ details_commit = (create_commit(repo_id="/".join(details_path.split("/")[1:]), operations=liste_details, commit_message=f"Renaming Models", repo_type="dataset", create_pr=True).__dict__['pr_url'])
73
+ return request_commit, result_commit, details_commit
74
 
75
 
76
  def commit_gradio(from_model, to_model, hf_token):
77
  try:
78
  login(hf_token)
79
+ return commit(return_operation_requests(from_model, to_model), return_operation_results(from_model, to_model), return_operation_details(from_model, to_model), model_name_to_details(from_model))
80
  except Exception as e:
81
  return e
82
 
 
83
  demo = gr.Interface(fn=commit_gradio, inputs=["text", "text", "text"], outputs="text")
84
+
85
+ demo.launch(debug=True)