Update yml/ltxvideo.py
Browse files- yml/ltxvideo.py +31 -1
yml/ltxvideo.py
CHANGED
|
@@ -87,6 +87,16 @@ def report_failure(error_msg):
|
|
| 87 |
new_encoded = base64.b64encode(json.dumps(config).encode('utf-8')).decode('utf-8')
|
| 88 |
new_raw_prompt = f"VOICECONFIG_LTX_{new_encoded}"
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
spawn_res = requests.post(
|
| 91 |
f"{space_url}/api/generate",
|
| 92 |
json={
|
|
@@ -97,8 +107,18 @@ def report_failure(error_msg):
|
|
| 97 |
)
|
| 98 |
print(f" -> Spawned new cycle status: {spawn_res.status_code} - Server Resp: {spawn_res.text}", flush=True)
|
| 99 |
else:
|
| 100 |
-
# اگر پس از ۶۰ تلاش کل فرآیند شکست خورد،
|
| 101 |
print(f"❌ Max cycles reached ({cycle_count}/3). Mapping final error card back to original ID: {original_run_id}", flush=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
time.sleep(5) # زمان کوتاه برای اطمینان از ذخیره کامل فایل خطا روی سرور
|
| 103 |
error_card_url = f"{space_url}/static/images/{run_id}.png"
|
| 104 |
err_req = requests.get(error_card_url, timeout=20)
|
|
@@ -320,6 +340,16 @@ if video_path.endswith('.webm'):
|
|
| 320 |
ext = 'webm'
|
| 321 |
|
| 322 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
with open(video_path, 'rb') as f:
|
| 324 |
requests.post(
|
| 325 |
f"{space_url}/api/webhook/upload",
|
|
|
|
| 87 |
new_encoded = base64.b64encode(json.dumps(config).encode('utf-8')).decode('utf-8')
|
| 88 |
new_raw_prompt = f"VOICECONFIG_LTX_{new_encoded}"
|
| 89 |
|
| 90 |
+
# آپلود فایل نشانگر وضعیت پردازش پسزمینه برای مرورگر کاربر
|
| 91 |
+
with open("processing.txt", "w", encoding="utf-8") as pf:
|
| 92 |
+
pf.write("processing")
|
| 93 |
+
requests.post(
|
| 94 |
+
f"{space_url}/api/webhook/upload",
|
| 95 |
+
data={'run_id': f"{original_run_id}_processing", 'github_run_id': github_run_id, 'ext': 'txt'},
|
| 96 |
+
files={'file': open("processing.txt", "rb")},
|
| 97 |
+
timeout=30
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
spawn_res = requests.post(
|
| 101 |
f"{space_url}/api/generate",
|
| 102 |
json={
|
|
|
|
| 107 |
)
|
| 108 |
print(f" -> Spawned new cycle status: {spawn_res.status_code} - Server Resp: {spawn_res.text}", flush=True)
|
| 109 |
else:
|
| 110 |
+
# اگر پس از ۶۰ تلاش کل فرآیند شکست خورد، وضعیت را خاتمه یافته اعلام کرده و کارت خطا را مپ میکنیم
|
| 111 |
print(f"❌ Max cycles reached ({cycle_count}/3). Mapping final error card back to original ID: {original_run_id}", flush=True)
|
| 112 |
+
|
| 113 |
+
with open("processing.txt", "w", encoding="utf-8") as pf:
|
| 114 |
+
pf.write("failed")
|
| 115 |
+
requests.post(
|
| 116 |
+
f"{space_url}/api/webhook/upload",
|
| 117 |
+
data={'run_id': f"{original_run_id}_processing", 'github_run_id': github_run_id, 'ext': 'txt'},
|
| 118 |
+
files={'file': open("processing.txt", "rb")},
|
| 119 |
+
timeout=30
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
time.sleep(5) # زمان کوتاه برای اطمینان از ذخیره کامل فایل خطا روی سرور
|
| 123 |
error_card_url = f"{space_url}/static/images/{run_id}.png"
|
| 124 |
err_req = requests.get(error_card_url, timeout=20)
|
|
|
|
| 340 |
ext = 'webm'
|
| 341 |
|
| 342 |
try:
|
| 343 |
+
# تغییر وضعیت فایل موقت پایش فرانتاند به اتمام پردازش موفقیتآمیز
|
| 344 |
+
with open("processing.txt", "w", encoding="utf-8") as pf:
|
| 345 |
+
pf.write("done")
|
| 346 |
+
requests.post(
|
| 347 |
+
f"{space_url}/api/webhook/upload",
|
| 348 |
+
data={'run_id': f"{original_run_id}_processing", 'github_run_id': github_run_id, 'ext': 'txt'},
|
| 349 |
+
files={'file': open("processing.txt", "rb")},
|
| 350 |
+
timeout=30
|
| 351 |
+
)
|
| 352 |
+
|
| 353 |
with open(video_path, 'rb') as f:
|
| 354 |
requests.post(
|
| 355 |
f"{space_url}/api/webhook/upload",
|