Update app.py
Browse files
app.py
CHANGED
|
@@ -59,8 +59,8 @@ VIDEOS_PER_BATCH = 10
|
|
| 59 |
TASKS_ROOT_DIR = "tasks_data"
|
| 60 |
|
| 61 |
# 🔥🔥 极限并发 🔥🔥
|
| 62 |
-
VIDEO_WORKERS = 5000
|
| 63 |
-
LLM_WORKERS = 5000
|
| 64 |
RENDER_PARALLELISM = 4 # 渲染线程保持4以防爆内存
|
| 65 |
|
| 66 |
# 全局渲染锁
|
|
@@ -849,6 +849,11 @@ def submit_batch_tasks(sys_prompt, *file_lists):
|
|
| 849 |
except Exception as e:
|
| 850 |
skipped_info.append(f"窗口 #{task['index']} 启动报错: {str(e)}")
|
| 851 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 852 |
# 构建返回消息
|
| 853 |
msg_lines = [f"🚀 成功启动 {len(started_ids)} 个任务!"]
|
| 854 |
msg_lines.append(f"ID: {', '.join(started_ids)}")
|
|
@@ -860,7 +865,8 @@ def submit_batch_tasks(sys_prompt, *file_lists):
|
|
| 860 |
|
| 861 |
def refresh_task_list():
|
| 862 |
tasks = task_manager.list_tasks()
|
| 863 |
-
|
|
|
|
| 864 |
|
| 865 |
def get_task_details(task_id):
|
| 866 |
if not task_id: return "请选择任务", None, None
|
|
@@ -870,7 +876,7 @@ def get_task_details(task_id):
|
|
| 870 |
|
| 871 |
def handle_clear_storage():
|
| 872 |
success, msg = task_manager.clear_all_tasks()
|
| 873 |
-
return msg, gr.
|
| 874 |
|
| 875 |
# ================= UI 构建 =================
|
| 876 |
|
|
@@ -908,7 +914,8 @@ with gr.Blocks(title="Veo V9.3 Grid Batch Edition") as demo:
|
|
| 908 |
with gr.Row():
|
| 909 |
with gr.Column(scale=1):
|
| 910 |
refresh_list_btn = gr.Button("🔄 刷新任务列表")
|
| 911 |
-
|
|
|
|
| 912 |
status_display = gr.Label("当前状态: 准备就绪")
|
| 913 |
download_file = gr.File(label="下载成品 (ZIP)")
|
| 914 |
|
|
@@ -927,11 +934,15 @@ with gr.Blocks(title="Veo V9.3 Grid Batch Edition") as demo:
|
|
| 927 |
outputs=[submit_result, new_task_id_storage]
|
| 928 |
)
|
| 929 |
|
|
|
|
| 930 |
def auto_select_new_task(new_id):
|
| 931 |
all_tasks = task_manager.list_tasks()
|
| 932 |
-
if new_id
|
| 933 |
-
|
| 934 |
-
|
|
|
|
|
|
|
|
|
|
| 935 |
|
| 936 |
submit_btn.click(auto_select_new_task, new_task_id_storage, task_dropdown)
|
| 937 |
refresh_list_btn.click(refresh_task_list, outputs=task_dropdown)
|
|
|
|
| 59 |
TASKS_ROOT_DIR = "tasks_data"
|
| 60 |
|
| 61 |
# 🔥🔥 极限并发 🔥🔥
|
| 62 |
+
VIDEO_WORKERS = 5000
|
| 63 |
+
LLM_WORKERS = 5000
|
| 64 |
RENDER_PARALLELISM = 4 # 渲染线程保持4以防爆内存
|
| 65 |
|
| 66 |
# 全局渲染锁
|
|
|
|
| 849 |
except Exception as e:
|
| 850 |
skipped_info.append(f"窗口 #{task['index']} 启动报错: {str(e)}")
|
| 851 |
|
| 852 |
+
# 🔥 核心修复:防止 started_ids 为空导致 crash
|
| 853 |
+
if not started_ids:
|
| 854 |
+
err_msg = "❌ 所有任务启动失败,请检查以下错误信息:\n" + "\n".join(skipped_info)
|
| 855 |
+
return err_msg, None
|
| 856 |
+
|
| 857 |
# 构建返回消息
|
| 858 |
msg_lines = [f"🚀 成功启动 {len(started_ids)} 个任务!"]
|
| 859 |
msg_lines.append(f"ID: {', '.join(started_ids)}")
|
|
|
|
| 865 |
|
| 866 |
def refresh_task_list():
|
| 867 |
tasks = task_manager.list_tasks()
|
| 868 |
+
# 🔥 核心修复:原子更新
|
| 869 |
+
return gr.update(choices=tasks, value=tasks[0] if tasks else None)
|
| 870 |
|
| 871 |
def get_task_details(task_id):
|
| 872 |
if not task_id: return "请选择任务", None, None
|
|
|
|
| 876 |
|
| 877 |
def handle_clear_storage():
|
| 878 |
success, msg = task_manager.clear_all_tasks()
|
| 879 |
+
return msg, gr.update(choices=[], value=None)
|
| 880 |
|
| 881 |
# ================= UI 构建 =================
|
| 882 |
|
|
|
|
| 914 |
with gr.Row():
|
| 915 |
with gr.Column(scale=1):
|
| 916 |
refresh_list_btn = gr.Button("🔄 刷新任务列表")
|
| 917 |
+
# 🔥 核心修复:allow_custom_value 防止验证报错
|
| 918 |
+
task_dropdown = gr.Dropdown(label="选择历史任务", choices=[], interactive=True, allow_custom_value=True)
|
| 919 |
status_display = gr.Label("当前状态: 准备就绪")
|
| 920 |
download_file = gr.File(label="下载成品 (ZIP)")
|
| 921 |
|
|
|
|
| 934 |
outputs=[submit_result, new_task_id_storage]
|
| 935 |
)
|
| 936 |
|
| 937 |
+
# 🔥 核心修复:原子更新函数
|
| 938 |
def auto_select_new_task(new_id):
|
| 939 |
all_tasks = task_manager.list_tasks()
|
| 940 |
+
if new_id:
|
| 941 |
+
if new_id not in all_tasks:
|
| 942 |
+
all_tasks.insert(0, new_id)
|
| 943 |
+
# 使用 gr.update 同时更新列表和值
|
| 944 |
+
return gr.update(choices=all_tasks, value=new_id)
|
| 945 |
+
return gr.update(choices=all_tasks, value=all_tasks[0] if all_tasks else None)
|
| 946 |
|
| 947 |
submit_btn.click(auto_select_new_task, new_task_id_storage, task_dropdown)
|
| 948 |
refresh_list_btn.click(refresh_task_list, outputs=task_dropdown)
|