Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
Β·
01f0578
1
Parent(s):
e9e4a75
Refactor submission messages for clarity and add emojis for better user experience
Browse files
utils.py
CHANGED
@@ -78,7 +78,7 @@ def submit_model(model_name, revision, precision, params, license, task):
|
|
78 |
elif task == "Reranker":
|
79 |
df = load_reranking_results()
|
80 |
else:
|
81 |
-
return
|
82 |
|
83 |
existing_models_results = df[['Model', 'Revision', 'Precision', 'Task']]
|
84 |
|
@@ -98,7 +98,7 @@ def submit_model(model_name, revision, precision, params, license, task):
|
|
98 |
(existing_models_results['Precision'] == precision) &
|
99 |
(existing_models_results['Task'] == task)).any()
|
100 |
if model_exists_in_results:
|
101 |
-
return
|
102 |
|
103 |
# Check if model is in pending requests
|
104 |
if not df_pending.empty:
|
@@ -108,7 +108,7 @@ def submit_model(model_name, revision, precision, params, license, task):
|
|
108 |
(existing_models_pending['precision'] == precision) &
|
109 |
(existing_models_pending['task'] == task)).any()
|
110 |
if model_exists_in_pending:
|
111 |
-
return
|
112 |
|
113 |
# Check if model is in finished requests
|
114 |
if not df_finished.empty:
|
@@ -118,14 +118,14 @@ def submit_model(model_name, revision, precision, params, license, task):
|
|
118 |
(existing_models_finished['precision'] == precision) &
|
119 |
(existing_models_finished['task'] == task)).any()
|
120 |
if model_exists_in_finished:
|
121 |
-
return
|
122 |
|
123 |
# Check if model exists on HuggingFace Hub
|
124 |
try:
|
125 |
api.model_info(model_name)
|
126 |
except Exception as e:
|
127 |
print(f"Error fetching model info: {e}")
|
128 |
-
return
|
129 |
|
130 |
# Proceed with submission
|
131 |
status = "PENDING"
|
@@ -147,7 +147,7 @@ def submit_model(model_name, revision, precision, params, license, task):
|
|
147 |
# Define the file path in the repository
|
148 |
org_model = model_name.split('/')
|
149 |
if len(org_model) != 2:
|
150 |
-
return "
|
151 |
org, model_id = org_model
|
152 |
precision_str = precision if precision else 'Missing'
|
153 |
file_path_in_repo = f"pending/{org}/{model_id}_eval_request_{revision}_{precision_str}_{task.lower()}.json"
|
@@ -163,9 +163,9 @@ def submit_model(model_name, revision, precision, params, license, task):
|
|
163 |
)
|
164 |
except Exception as e:
|
165 |
print(f"Error uploading file: {e}")
|
166 |
-
return
|
167 |
|
168 |
-
return f"
|
169 |
|
170 |
def load_requests(status_folder, task_type=None):
|
171 |
api = HfApi()
|
@@ -254,7 +254,7 @@ def submit_gradio_module(task_type):
|
|
254 |
)
|
255 |
|
256 |
submit_button = gr.Button("Submit Model", variant="primary")
|
257 |
-
submission_result = gr.
|
258 |
fetch_outputs = [precision_input, license_input, params_input, num_downloads_input, num_likes_input]
|
259 |
|
260 |
fetch_data_button.click(
|
|
|
78 |
elif task == "Reranker":
|
79 |
df = load_reranking_results()
|
80 |
else:
|
81 |
+
return "Task is not supported π€·ββοΈ"
|
82 |
|
83 |
existing_models_results = df[['Model', 'Revision', 'Precision', 'Task']]
|
84 |
|
|
|
98 |
(existing_models_results['Precision'] == precision) &
|
99 |
(existing_models_results['Task'] == task)).any()
|
100 |
if model_exists_in_results:
|
101 |
+
return f"Model {model_name} has already been evaluated as a {task} π"
|
102 |
|
103 |
# Check if model is in pending requests
|
104 |
if not df_pending.empty:
|
|
|
108 |
(existing_models_pending['precision'] == precision) &
|
109 |
(existing_models_pending['task'] == task)).any()
|
110 |
if model_exists_in_pending:
|
111 |
+
return f"Model {model_name} is already in the evaluation queue as a {task} π"
|
112 |
|
113 |
# Check if model is in finished requests
|
114 |
if not df_finished.empty:
|
|
|
118 |
(existing_models_finished['precision'] == precision) &
|
119 |
(existing_models_finished['task'] == task)).any()
|
120 |
if model_exists_in_finished:
|
121 |
+
return f"Model {model_name} has already been evaluated as a {task} π"
|
122 |
|
123 |
# Check if model exists on HuggingFace Hub
|
124 |
try:
|
125 |
api.model_info(model_name)
|
126 |
except Exception as e:
|
127 |
print(f"Error fetching model info: {e}")
|
128 |
+
return f"Model {model_name} not found on HuggingFace Hub π€·ββοΈ"
|
129 |
|
130 |
# Proceed with submission
|
131 |
status = "PENDING"
|
|
|
147 |
# Define the file path in the repository
|
148 |
org_model = model_name.split('/')
|
149 |
if len(org_model) != 2:
|
150 |
+
return "Please enter the full model name including the organization or username, e.g., 'intfloat/multilingual-e5-large-instruct' π€·ββοΈ"
|
151 |
org, model_id = org_model
|
152 |
precision_str = precision if precision else 'Missing'
|
153 |
file_path_in_repo = f"pending/{org}/{model_id}_eval_request_{revision}_{precision_str}_{task.lower()}.json"
|
|
|
163 |
)
|
164 |
except Exception as e:
|
165 |
print(f"Error uploading file: {e}")
|
166 |
+
return f"Error: Could not submit model '{model_name}' for evaluation."
|
167 |
|
168 |
+
return f"Model {model_name} has been submitted successfully as a {task} π"
|
169 |
|
170 |
def load_requests(status_folder, task_type=None):
|
171 |
api = HfApi()
|
|
|
254 |
)
|
255 |
|
256 |
submit_button = gr.Button("Submit Model", variant="primary")
|
257 |
+
submission_result = gr.Textbox(label="Submission Result", interactive=False)
|
258 |
fetch_outputs = [precision_input, license_input, params_input, num_downloads_input, num_likes_input]
|
259 |
|
260 |
fetch_data_button.click(
|