Spaces:
Running
Running
fix deploy
Browse files- backend_deploy.py +12 -12
backend_deploy.py
CHANGED
|
@@ -541,9 +541,9 @@ def deploy_to_huggingface_space(
|
|
| 541 |
print(f"[Deploy] language: {language}")
|
| 542 |
print(f"[Deploy] ============================================")
|
| 543 |
|
| 544 |
-
# For Gradio space updates (import/redesign),
|
| 545 |
if is_update and language == "gradio":
|
| 546 |
-
print(f"[Deploy] Gradio space update -
|
| 547 |
|
| 548 |
# Parse the code to get all files
|
| 549 |
files = parse_multi_file_python_output(code)
|
|
@@ -554,18 +554,18 @@ def deploy_to_huggingface_space(
|
|
| 554 |
cleaned_code = remove_code_block(code)
|
| 555 |
files['app.py'] = cleaned_code
|
| 556 |
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
if not py_files:
|
| 561 |
-
return False, "Error: No Python files found in generated code", None
|
| 562 |
|
| 563 |
-
print(f"[Deploy]
|
| 564 |
|
| 565 |
-
#
|
|
|
|
|
|
|
|
|
|
| 566 |
updated_files = []
|
| 567 |
-
for file_path, content in
|
| 568 |
-
print(f"[Deploy]
|
| 569 |
success, msg = update_space_file(
|
| 570 |
repo_id=existing_repo_id,
|
| 571 |
file_path=file_path,
|
|
@@ -584,7 +584,7 @@ def deploy_to_huggingface_space(
|
|
| 584 |
files_list = ", ".join(updated_files)
|
| 585 |
return True, f"✅ Updated {len(updated_files)} file(s): {files_list}! View at: {space_url}", space_url
|
| 586 |
else:
|
| 587 |
-
return False, "Failed to update any
|
| 588 |
|
| 589 |
if is_update:
|
| 590 |
# Use existing repo
|
|
|
|
| 541 |
print(f"[Deploy] language: {language}")
|
| 542 |
print(f"[Deploy] ============================================")
|
| 543 |
|
| 544 |
+
# For Gradio space updates (import/redesign), update .py files and upload all new files
|
| 545 |
if is_update and language == "gradio":
|
| 546 |
+
print(f"[Deploy] Gradio space update - updating .py files and uploading any new files")
|
| 547 |
|
| 548 |
# Parse the code to get all files
|
| 549 |
files = parse_multi_file_python_output(code)
|
|
|
|
| 554 |
cleaned_code = remove_code_block(code)
|
| 555 |
files['app.py'] = cleaned_code
|
| 556 |
|
| 557 |
+
if not files:
|
| 558 |
+
return False, "Error: No files found in generated code", None
|
|
|
|
|
|
|
|
|
|
| 559 |
|
| 560 |
+
print(f"[Deploy] Generated {len(files)} file(s): {list(files.keys())}")
|
| 561 |
|
| 562 |
+
# Upload all generated files (the LLM is instructed to only output .py files,
|
| 563 |
+
# but if it creates new assets/data files, we should upload those too)
|
| 564 |
+
# This approach updates .py files and adds any new files without touching
|
| 565 |
+
# existing non-.py files that weren't generated
|
| 566 |
updated_files = []
|
| 567 |
+
for file_path, content in files.items():
|
| 568 |
+
print(f"[Deploy] Uploading {file_path} ({len(content)} chars)")
|
| 569 |
success, msg = update_space_file(
|
| 570 |
repo_id=existing_repo_id,
|
| 571 |
file_path=file_path,
|
|
|
|
| 584 |
files_list = ", ".join(updated_files)
|
| 585 |
return True, f"✅ Updated {len(updated_files)} file(s): {files_list}! View at: {space_url}", space_url
|
| 586 |
else:
|
| 587 |
+
return False, "Failed to update any files", None
|
| 588 |
|
| 589 |
if is_update:
|
| 590 |
# Use existing repo
|