Spaces:
Sleeping
Sleeping
indent error
Browse files
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 |
-
|
| 214 |
-
|
| 215 |
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
if
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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:
|