Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
ba07ad3
1
Parent(s):
d787cff
Refactor submit_model function to handle task-specific logic and improve error messages
Browse files
utils.py
CHANGED
@@ -46,9 +46,14 @@ def fetch_model_information(model_name):
|
|
46 |
|
47 |
def submit_model(model_name, revision, precision, params, license, task):
|
48 |
# Load existing evaluations
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
-
existing_models_results =
|
52 |
|
53 |
# Handle 'Missing' precision
|
54 |
if precision == 'Missing':
|
@@ -93,7 +98,7 @@ def submit_model(model_name, revision, precision, params, license, task):
|
|
93 |
api.model_info(model_name)
|
94 |
except Exception as e:
|
95 |
print(f"Error fetching model info: {e}")
|
96 |
-
return gr.Error(f"
|
97 |
|
98 |
# Proceed with submission
|
99 |
status = "PENDING"
|
@@ -118,7 +123,7 @@ def submit_model(model_name, revision, precision, params, license, task):
|
|
118 |
return "**Please enter the full model name including the organization or username, e.g., 'intfloat/multilingual-e5-large-instruct'**"
|
119 |
org, model_id = org_model
|
120 |
precision_str = precision if precision else 'Missing'
|
121 |
-
file_path_in_repo = f"pending/{org}/{model_id}_eval_request_{revision}_{precision_str}_{task}.json"
|
122 |
|
123 |
# Upload the submission to the dataset repository
|
124 |
try:
|
@@ -131,9 +136,10 @@ def submit_model(model_name, revision, precision, params, license, task):
|
|
131 |
token=hf_api_token
|
132 |
)
|
133 |
except Exception as e:
|
134 |
-
|
|
|
135 |
|
136 |
-
return f"**Model '{model_name}' has been submitted
|
137 |
|
138 |
def load_requests(status_folder):
|
139 |
api = HfApi()
|
|
|
46 |
|
47 |
def submit_model(model_name, revision, precision, params, license, task):
|
48 |
# Load existing evaluations
|
49 |
+
if task == "Retriever":
|
50 |
+
df = load_retrieval_results()
|
51 |
+
elif task == "Reranker":
|
52 |
+
df = load_retrieval_results()
|
53 |
+
else:
|
54 |
+
return gr.Error(f"Error: Task '{task}' is not supported.")
|
55 |
|
56 |
+
existing_models_results = df[['Model', 'Revision', 'Precision', 'Task']]
|
57 |
|
58 |
# Handle 'Missing' precision
|
59 |
if precision == 'Missing':
|
|
|
98 |
api.model_info(model_name)
|
99 |
except Exception as e:
|
100 |
print(f"Error fetching model info: {e}")
|
101 |
+
return gr.Error(f"Error: Model '{model_name}' not found on HuggingFace Hub.")
|
102 |
|
103 |
# Proceed with submission
|
104 |
status = "PENDING"
|
|
|
123 |
return "**Please enter the full model name including the organization or username, e.g., 'intfloat/multilingual-e5-large-instruct'**"
|
124 |
org, model_id = org_model
|
125 |
precision_str = precision if precision else 'Missing'
|
126 |
+
file_path_in_repo = f"pending/{org}/{model_id}_eval_request_{revision}_{precision_str}_{task.lower()}.json"
|
127 |
|
128 |
# Upload the submission to the dataset repository
|
129 |
try:
|
|
|
136 |
token=hf_api_token
|
137 |
)
|
138 |
except Exception as e:
|
139 |
+
print(f"Error uploading file: {e}")
|
140 |
+
return gr.Error(f"Error: Could not submit model '{model_name}' for evaluation.")
|
141 |
|
142 |
+
return f"**Model '{model_name}' with revision '{revision}' and precision '{precision}' for task '{task}' has been submitted successfully.**"
|
143 |
|
144 |
def load_requests(status_folder):
|
145 |
api = HfApi()
|