Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

raea cloud: the farm names its User-Agent, and a job whose media didn't come still answers /out (CR23)

shinyobjectz39639485d255
diff --git a/sdk/cloud/deploy/modal/farm.py b/sdk/cloud/deploy/modal/farm.py
index 98f3567c..3210d821 100644
--- a/sdk/cloud/deploy/modal/farm.py
+++ b/sdk/cloud/deploy/modal/farm.py
@@ -238,6 +238,7 @@ def coordinate(id: str, args: list[str], opts: dict):
farm_media.fetch(work, f"{ROOT}/blobs", log)
except Exception as e: # a file that didn't come, or came back as another: the job doesn't run
log(f"raea farm: {e}", err=True)
+ open(f"{JOBS}/{id}/changed.txt", "w").close() # nothing made: /out answers with an empty tar
vol.commit()
log.end(1)
return
diff --git a/sdk/cloud/deploy/modal/farm_media.py b/sdk/cloud/deploy/modal/farm_media.py
index f0ee9a25..8ae4e640 100644
--- a/sdk/cloud/deploy/modal/farm_media.py
+++ b/sdk/cloud/deploy/modal/farm_media.py
@@ -24,6 +24,8 @@ MEDIA = set(
)
LARGE = 4 * 1024 * 1024
CHUNK = 1 << 20
+# Cloudflare refuses Python's own User-Agent (Python-urllib) on raea's domains with a 403, signed URL or not
+AGENT = {"user-agent": "raea-farm/1"}
def sha256(path):
@@ -40,7 +42,7 @@ def inside(work, rel):
def get(href, header, dest):
- req = urllib.request.Request(href, headers=header or {})
+ req = urllib.request.Request(href, headers={**AGENT, **(header or {})})
with urllib.request.urlopen(req, timeout=600) as r, open(dest, "wb") as f:
shutil.copyfileobj(r, f, CHUNK)
@@ -48,7 +50,7 @@ def get(href, header, dest):
def put(href, header, src, size):
with open(src, "rb") as f:
# as git-lfs's basic transfer sends it
- head = {"content-type": "application/octet-stream", **(header or {}), "content-length": str(size)}
+ head = {**AGENT, "content-type": "application/octet-stream", **(header or {}), "content-length": str(size)}
req = urllib.request.Request(href, data=f, method="PUT", headers=head)
with urllib.request.urlopen(req, timeout=1800) as r:
r.read()