saraht14 commited on
Commit
71b637e
·
verified ·
1 Parent(s): f025136

indent error

Browse files
Files changed (1) hide show
  1. app.py +26 -21
app.py CHANGED
@@ -210,28 +210,33 @@ def import_and_run_function(script_path, function_name="eval"):
210
  if not zip_file:
211
  return "No file uploaded."
212
 
213
- zip_path = zip_file.name
214
- extract_path = os.path.join(UPLOAD_FOLDER, username)
215
 
216
- os.makedirs(extract_path)
217
-
218
- try:
219
- with zipfile.ZipFile(zip_path, "r") as zip_ref:
220
- zip_ref.extractall(extract_path)
221
- except zipfile.BadZipFile:
222
- return "Invalid ZIP file."
223
-
224
- install_requirements()
225
- python_script = None
226
- for file in os.listdir(extract_path):
227
- if file.endswith(".py"):
228
- python_script = os.path.join(extract_path, file)
229
- break
230
-
231
- if not python_script:
232
- return "No Python script found in ZIP."
233
- updated_leaderboard = evaluate_model(username, file)
234
- return updated_leaderboard
 
 
 
 
 
235
 
236
 
237
  with gr.Blocks() as demo:
 
210
  if not zip_file:
211
  return "No file uploaded."
212
 
213
+ zip_path = zip_file.name # Correct indentation
214
+ extract_path = os.path.join(UPLOAD_FOLDER, username)
215
 
216
+ os.makedirs(extract_path)
217
+
218
+ try:
219
+ with zipfile.ZipFile(zip_path, "r") as zip_ref:
220
+ zip_ref.extractall(extract_path)
221
+ except zipfile.BadZipFile:
222
+ return "Invalid ZIP file."
223
+
224
+ # Check for requirements.txt and install dependencies
225
+ req_file = os.path.join(extract_path, "requirements.txt")
226
+ install_requirements(req_file) # Pass the correct path
227
+
228
+ # Find the Python script
229
+ python_script = None
230
+ for file in os.listdir(extract_path):
231
+ if file.endswith(".py"):
232
+ python_script = os.path.join(extract_path, file)
233
+ break
234
+
235
+ if not python_script:
236
+ return "No Python script found in ZIP."
237
+
238
+ updated_leaderboard = evaluate_model(username, python_script) # Pass the script
239
+ return updated_leaderboard
240
 
241
 
242
  with gr.Blocks() as demo: