AdhyanshVerma commited on
Commit
b9fbe60
·
verified ·
1 Parent(s): 22ea2f8

Upload 4 files

Browse files
Files changed (2) hide show
  1. app.py +10 -0
  2. pipeline/orchestrator.py +1 -1
app.py CHANGED
@@ -426,6 +426,14 @@ def run_v3_status():
426
  except Exception as e:
427
  return f"Error: {e}"
428
 
 
 
 
 
 
 
 
 
429
  with gr.Blocks() as app:
430
  gr.Markdown("# YouTube Video Orchestrator Host")
431
  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.")
@@ -442,12 +450,14 @@ with gr.Blocks() as app:
442
  v3_launch_btn = gr.Button("Launch Workers (--push)", variant="primary")
443
  v3_sync_btn = gr.Button("Sync DB & Status")
444
  v3_status_btn = gr.Button("Check Status")
 
445
 
446
  v3_output_log = gr.Textbox(label="Terminal Output", lines=15)
447
 
448
  v3_launch_btn.click(fn=run_v3_launch, inputs=[v3_max_workers, v3_videos], outputs=v3_output_log)
449
  v3_sync_btn.click(fn=run_v3_sync, inputs=[], outputs=v3_output_log)
450
  v3_status_btn.click(fn=run_v3_status, inputs=[], outputs=v3_output_log)
 
451
 
452
  with gr.Tab("Database Sync"):
453
  gr.Markdown("Sync (Add) new API keys and YouTube Links into your database.")
 
426
  except Exception as e:
427
  return f"Error: {e}"
428
 
429
+ def run_v3_retry():
430
+ cmd = ["python", "pipeline/orchestrator.py", "retry"]
431
+ try:
432
+ res = subprocess.run(cmd, capture_output=True, text=True, cwd=os.path.dirname(os.path.abspath(__file__)))
433
+ return f"--- RETRY OUTPUT ---\n{res.stdout}\n{res.stderr}"
434
+ except Exception as e:
435
+ return f"Error: {e}"
436
+
437
  with gr.Blocks() as app:
438
  gr.Markdown("# YouTube Video Orchestrator Host")
439
  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.")
 
450
  v3_launch_btn = gr.Button("Launch Workers (--push)", variant="primary")
451
  v3_sync_btn = gr.Button("Sync DB & Status")
452
  v3_status_btn = gr.Button("Check Status")
453
+ v3_retry_btn = gr.Button("Retry Failed Videos")
454
 
455
  v3_output_log = gr.Textbox(label="Terminal Output", lines=15)
456
 
457
  v3_launch_btn.click(fn=run_v3_launch, inputs=[v3_max_workers, v3_videos], outputs=v3_output_log)
458
  v3_sync_btn.click(fn=run_v3_sync, inputs=[], outputs=v3_output_log)
459
  v3_status_btn.click(fn=run_v3_status, inputs=[], outputs=v3_output_log)
460
+ v3_retry_btn.click(fn=run_v3_retry, inputs=[], outputs=v3_output_log)
461
 
462
  with gr.Tab("Database Sync"):
463
  gr.Markdown("Sync (Add) new API keys and YouTube Links into your database.")
pipeline/orchestrator.py CHANGED
@@ -179,7 +179,7 @@ class Tracker:
179
 
180
  def retry_failed(self, max_retries=3):
181
  with self._conn() as c:
182
- r = c.execute("UPDATE videos SET status=? WHERE status IN (?,?) AND retry_count<?",
183
  (S_PENDING, S_FAILED, S_TIMEOUT, max_retries))
184
  return r.rowcount
185
 
 
179
 
180
  def retry_failed(self, max_retries=3):
181
  with self._conn() as c:
182
+ r = c.execute("UPDATE videos SET status=?, retry_count=retry_count+1 WHERE status IN (?,?) AND retry_count<?",
183
  (S_PENDING, S_FAILED, S_TIMEOUT, max_retries))
184
  return r.rowcount
185