Spaces:
Running on Zero
Running on Zero
gracefully skip R2 upload when SCONFIG not set
Browse files
app.py
CHANGED
|
@@ -1434,23 +1434,26 @@ def generate_and_upload(
|
|
| 1434 |
"seed": int(used),
|
| 1435 |
"uid": uid,
|
| 1436 |
}
|
| 1437 |
-
|
| 1438 |
-
|
| 1439 |
-
|
| 1440 |
-
|
| 1441 |
-
|
| 1442 |
-
|
| 1443 |
-
|
| 1444 |
-
|
| 1445 |
-
|
| 1446 |
-
|
| 1447 |
-
|
| 1448 |
-
|
| 1449 |
-
|
| 1450 |
-
|
| 1451 |
-
|
| 1452 |
-
|
| 1453 |
-
|
|
|
|
|
|
|
|
|
|
| 1454 |
status["moderation"] = moderation
|
| 1455 |
yield image, used, status, _progress("done", 1.0, label="Done")
|
| 1456 |
|
|
@@ -1617,16 +1620,19 @@ def prompt_to_video_assets(
|
|
| 1617 |
"source": "prompt_to_video_assets",
|
| 1618 |
"original_input": original_input,
|
| 1619 |
}
|
| 1620 |
-
|
| 1621 |
-
|
| 1622 |
-
|
| 1623 |
-
|
| 1624 |
-
|
| 1625 |
-
|
| 1626 |
-
|
| 1627 |
-
|
| 1628 |
-
|
| 1629 |
-
|
|
|
|
|
|
|
|
|
|
| 1630 |
|
| 1631 |
# --- Stage 4: LLM writes the video prompt (grounded on the frame) ---------
|
| 1632 |
base += _P2V_W_UPLOAD
|
|
|
|
| 1434 |
"seed": int(used),
|
| 1435 |
"uid": uid,
|
| 1436 |
}
|
| 1437 |
+
try:
|
| 1438 |
+
result = r2_uploader.upload_asset(
|
| 1439 |
+
namespace=R2_NAMESPACE,
|
| 1440 |
+
prompt=effective_prompt,
|
| 1441 |
+
params=params,
|
| 1442 |
+
data=buf.getvalue(),
|
| 1443 |
+
ext=".webp",
|
| 1444 |
+
content_type="image/webp",
|
| 1445 |
+
uid=uid,
|
| 1446 |
+
)
|
| 1447 |
+
if result.get("ok"):
|
| 1448 |
+
status = {
|
| 1449 |
+
"r2_filekey": result["filekey"],
|
| 1450 |
+
"r2_bucket": result["bucket"],
|
| 1451 |
+
"r2_url": r2_uploader.presign_get_url(result["filekey"], result["bucket"]),
|
| 1452 |
+
}
|
| 1453 |
+
else:
|
| 1454 |
+
status = {"r2_error": result.get("error", "unknown error")}
|
| 1455 |
+
except Exception:
|
| 1456 |
+
status = {"r2_error": "SCONFIG not set R2 upload skipped"}
|
| 1457 |
status["moderation"] = moderation
|
| 1458 |
yield image, used, status, _progress("done", 1.0, label="Done")
|
| 1459 |
|
|
|
|
| 1620 |
"source": "prompt_to_video_assets",
|
| 1621 |
"original_input": original_input,
|
| 1622 |
}
|
| 1623 |
+
try:
|
| 1624 |
+
up = r2_uploader.upload_asset(
|
| 1625 |
+
namespace=R2_NAMESPACE, prompt=frame_prompt, params=params,
|
| 1626 |
+
data=buf.getvalue(), ext=".webp", content_type="image/webp", uid=uid,
|
| 1627 |
+
)
|
| 1628 |
+
if up.get("ok"):
|
| 1629 |
+
state["r2_filekey"] = up["filekey"]
|
| 1630 |
+
state["r2_bucket"] = up["bucket"]
|
| 1631 |
+
state["first_frame_url"] = r2_uploader.presign_get_url(up["filekey"], up["bucket"])
|
| 1632 |
+
else:
|
| 1633 |
+
state["error"] = up.get("error", "R2 upload failed")
|
| 1634 |
+
except Exception:
|
| 1635 |
+
state["error"] = "SCONFIG not set R2 upload skipped"
|
| 1636 |
|
| 1637 |
# --- Stage 4: LLM writes the video prompt (grounded on the frame) ---------
|
| 1638 |
base += _P2V_W_UPLOAD
|