Upload app.py
Browse files
app.py
CHANGED
|
@@ -442,6 +442,20 @@ def run_verify_repo(repo_id):
|
|
| 442 |
except Exception as e:
|
| 443 |
return f"Error: {e}"
|
| 444 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 445 |
with gr.Blocks() as app:
|
| 446 |
gr.Markdown("# YouTube Video Orchestrator Host")
|
| 447 |
gr.Markdown("Deploy this to Hugging Face Spaces or run locally. It fetches pending links from your database and delegates them to FastAPI workers or Kaggle.")
|
|
@@ -456,6 +470,7 @@ with gr.Blocks() as app:
|
|
| 456 |
|
| 457 |
with gr.Row():
|
| 458 |
v3_launch_btn = gr.Button("Launch Workers (--push)", variant="primary")
|
|
|
|
| 459 |
v3_sync_btn = gr.Button("Sync DB & Status")
|
| 460 |
v3_status_btn = gr.Button("Check Status")
|
| 461 |
v3_retry_btn = gr.Button("Retry Failed Videos")
|
|
@@ -470,6 +485,7 @@ with gr.Blocks() as app:
|
|
| 470 |
v3_output_log = gr.Textbox(label="Terminal Output", lines=15)
|
| 471 |
|
| 472 |
v3_launch_btn.click(fn=run_v3_launch, inputs=[v3_max_workers, v3_videos], outputs=v3_output_log)
|
|
|
|
| 473 |
v3_sync_btn.click(fn=run_v3_sync, inputs=[], outputs=v3_output_log)
|
| 474 |
v3_status_btn.click(fn=run_v3_status, inputs=[], outputs=v3_output_log)
|
| 475 |
v3_retry_btn.click(fn=run_v3_retry, inputs=[], outputs=v3_output_log)
|
|
|
|
| 442 |
except Exception as e:
|
| 443 |
return f"Error: {e}"
|
| 444 |
|
| 445 |
+
autopilot_process = None
|
| 446 |
+
|
| 447 |
+
def toggle_autopilot(videos_per_worker):
|
| 448 |
+
global autopilot_process
|
| 449 |
+
|
| 450 |
+
if autopilot_process is not None and autopilot_process.poll() is None:
|
| 451 |
+
autopilot_process.terminate()
|
| 452 |
+
autopilot_process = None
|
| 453 |
+
return "🛑 Autopilot stopped."
|
| 454 |
+
else:
|
| 455 |
+
cmd = ["python", "pipeline/orchestrator.py", "run", "--videos-per-worker", str(int(videos_per_worker))]
|
| 456 |
+
autopilot_process = subprocess.Popen(cmd, cwd=os.path.dirname(os.path.abspath(__file__)))
|
| 457 |
+
return "🚀 Autopilot started! It is now running continuously in the background, checking Kaggle every 2 minutes and instantly launching new workers whenever slots free up."
|
| 458 |
+
|
| 459 |
with gr.Blocks() as app:
|
| 460 |
gr.Markdown("# YouTube Video Orchestrator Host")
|
| 461 |
gr.Markdown("Deploy this to Hugging Face Spaces or run locally. It fetches pending links from your database and delegates them to FastAPI workers or Kaggle.")
|
|
|
|
| 470 |
|
| 471 |
with gr.Row():
|
| 472 |
v3_launch_btn = gr.Button("Launch Workers (--push)", variant="primary")
|
| 473 |
+
v3_autopilot_btn = gr.Button("Toggle Autopilot", variant="secondary")
|
| 474 |
v3_sync_btn = gr.Button("Sync DB & Status")
|
| 475 |
v3_status_btn = gr.Button("Check Status")
|
| 476 |
v3_retry_btn = gr.Button("Retry Failed Videos")
|
|
|
|
| 485 |
v3_output_log = gr.Textbox(label="Terminal Output", lines=15)
|
| 486 |
|
| 487 |
v3_launch_btn.click(fn=run_v3_launch, inputs=[v3_max_workers, v3_videos], outputs=v3_output_log)
|
| 488 |
+
v3_autopilot_btn.click(fn=toggle_autopilot, inputs=[v3_videos], outputs=v3_output_log)
|
| 489 |
v3_sync_btn.click(fn=run_v3_sync, inputs=[], outputs=v3_output_log)
|
| 490 |
v3_status_btn.click(fn=run_v3_status, inputs=[], outputs=v3_output_log)
|
| 491 |
v3_retry_btn.click(fn=run_v3_retry, inputs=[], outputs=v3_output_log)
|