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.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
raea cloud: raea's Modal apps in raea's own workspace, and this machine's logins for it beside any others
shinyobjectz094d9280132d
diff --git a/sdk/cloud/bench/gpus.py b/sdk/cloud/bench/gpus.pyindex 42c5cc9a..cb93764f 100644--- a/sdk/cloud/bench/gpus.py+++ b/sdk/cloud/bench/gpus.py@@ -1,9 +1,9 @@# raea cloud's GPU bench (docs/cloud-render.feature CR2): the same raea renders and Blender Cycles scenes on each# Modal GPU kind, so a render's price per frame is measured, not guessed. From sdk/cloud:#-# MODAL_PROFILE=shane-25168 modal run bench/gpus.py # every kind in KINDS-# MODAL_PROFILE=shane-25168 modal run bench/gpus.py --gpus L4,L40S # some-# MODAL_PROFILE=shane-25168 modal run bench/gpus.py --gpus none # the CPU only (llvmpipe, Cycles on CPU)+# MODAL_PROFILE=raea modal run bench/gpus.py # every kind in KINDS+# MODAL_PROFILE=raea modal run bench/gpus.py --gpus L4,L40S # some+# MODAL_PROFILE=raea modal run bench/gpus.py --gpus none # the CPU only (llvmpipe, Cycles on CPU)## Each kind runs in its own container at once, and writes bench/results/KIND.json:# - device: nvidia-smi's name, memory and driver; the Vulkan device raea openeddiff --git a/sdk/cloud/deploy/login.sh b/sdk/cloud/deploy/login.shnew file mode 100755index 00000000..bb061772--- /dev/null+++ b/sdk/cloud/deploy/login.sh@@ -0,0 +1,76 @@+#!/bin/bash+# This machine's logins for raea's own clouds, beside any others it has and without changing their defaults+# (docs/cloud-render.feature CR19): a Modal profile for raea's workspace, and a Sprites token for raea's Fly org, whose+# name goes in ~/.config/raea-cloud/sprites.env (where deploy/sprites/box.sh reads it).+#+# sdk/cloud/deploy/login.sh each one that's missing:+# Modal: a browser page asks you to approve; pick the raea workspace there.+# Sprites: first make a token at https://fly.io/dashboard/raea/sprites/tokens and+# copy it. It's read from the clipboard (never typed, so it stays out of chats+# and shell history), then the clipboard is cleared.+# sdk/cloud/deploy/login.sh check what this machine reaches, changing nothing+#+# RAEA_MODAL_WORKSPACE and RAEA_SPRITES_ORG (both raea) name them.+set -euo pipefail+WS=${RAEA_MODAL_WORKSPACE:-raea}+ORG=${RAEA_SPRITES_ORG:-raea}+CONF=$HOME/.config/raea-cloud/sprites.env+DENIED=$(git -C "$(dirname "$0")" rev-parse --show-toplevel 2>/dev/null)/private/cloud/sprites-denied.txt++profile_ws() {+ modal profile list --json 2>/dev/null | python3 -c 'import json, sys; print(next((x["workspace"] for x in json.load(sys.stdin) if x["name"] == sys.argv[1]), ""))' "$WS"+}+has_org() { sprite org list 2>/dev/null | grep -qE "^ *[0-9]+\. $ORG( |$)"; }+# a profile named raea whose token reaches another workspace would send raea's deploys there: it goes+drop_profile() {+ python3 - "$HOME/.modal.toml" "$WS" <<'EOF'+import re, sys+path, name = sys.argv[1], sys.argv[2]+text = open(path).read()+open(path, "w").write(re.sub(r"(?ms)^\[" + re.escape(name) + r"\]\n.*?(?=^\[|\Z)", "", text))+EOF+}++check() {+ local w+ w=$(profile_ws)+ if [ "$w" = "$WS" ]; then echo "modal: profile $WS reaches workspace $WS"; else echo "modal: no profile for workspace $WS"; fi+ if has_org; then echo "sprites: a token for org $ORG"; else echo "sprites: no token for org $ORG"; fi+ if [ -f "$CONF" ]; then echo "box.sh org: $(sed -n 's/^RAEA_SPRITES_ORG=//p' "$CONF")"; else echo "box.sh org: not set ($CONF)"; fi+}++if [ "${1:-}" = check ]; then+ check+ exit 0+fi++if [ "$(profile_ws)" != "$WS" ]; then+ echo "modal: approve in the browser page that opens, with the $WS workspace picked"+ modal token new --profile "$WS" --no-activate+ w=$(profile_ws)+ if [ "$w" != "$WS" ]; then+ drop_profile+ echo "modal: that approval was for workspace ${w:-unknown}, not $WS, so the profile was removed; run again and pick $WS"+ exit 1+ fi+fi++if ! has_org; then+ t=$(pbpaste 2>/dev/null | tr -d '[:space:]')+ case "$t" in+ "" | *" "*) echo "sprites: copy a token from https://fly.io/dashboard/$ORG/sprites/tokens, then run this again"; exit 1 ;;+ */*) ;;+ *) echo "sprites: the clipboard doesn't hold a Sprites token (they look like ORG/...); copy one and run this again"; exit 1 ;;+ esac+ if [ -f "$DENIED" ] && grep -qxF "${t%%/*}" "$DENIED"; then+ echo "sprites: that token is for ${t%%/*}, which belongs to another business; make one in $ORG"+ exit 1+ fi+ sprite auth setup --token "$t" >/dev/null+ printf '' | pbcopy+ has_org || { echo "sprites: the token was taken, but org $ORG isn't among this machine's orgs (sprite org list)"; exit 1; }+fi++mkdir -p "$(dirname "$CONF")"+(umask 077 && echo "RAEA_SPRITES_ORG=$ORG" >"$CONF")+checkdiff --git a/sdk/cloud/deploy/modal/farm.py b/sdk/cloud/deploy/modal/farm.pyindex 945ebdbc..daf9d8c2 100644--- a/sdk/cloud/deploy/modal/farm.py+++ b/sdk/cloud/deploy/modal/farm.py@@ -2,7 +2,7 @@# `raea render` (RAEA_CLOUD_GPU_URL, server/offload.ts) and the TypeScript client use it unchanged, with one render# split across many GPUs at once. From sdk/cloud:#-# MODAL_PROFILE=shane-25168 modal deploy deploy/modal/farm.py+# MODAL_PROFILE=raea modal deploy deploy/modal/farm.py## POST /v1/jobs?args=JSON[&gpus=N][&gpu=KIND][&max_usd=X] body: the project as a tar. {id}# GET /v1/jobs/ID?from=N {log, next, exit?}, held up to 20 s for morediff --git a/sdk/cloud/deploy/modal/guard.sh b/sdk/cloud/deploy/modal/guard.shnew file mode 100644index 00000000..1a891696--- /dev/null+++ b/sdk/cloud/deploy/modal/guard.sh@@ -0,0 +1,24 @@+# Sourced by raea's Modal scripts (workspace.sh, models.sh): MODAL_PROFILE must name a profile whose token reaches the+# workspace of the same name (raea's is raea; sdk/cloud/deploy/login.sh makes the profile), and never a workspace+# listed in private/cloud/modal-denied.txt (workspaces that belong to other businesses). The default profile is never+# used and never changed. (No ${VAR:?message} here: a quote in its message hides the lines after it.)+modal_guard() {+ local p=${MODAL_PROFILE:-} ws denied+ if [ -z "$p" ]; then+ echo "modal: set MODAL_PROFILE to raea's profile (sdk/cloud/deploy/login.sh makes it)"+ return 2+ fi+ ws=$(modal profile list --json 2>/dev/null | python3 -c 'import json, sys; print(next((x["workspace"] for x in json.load(sys.stdin) if x["name"] == sys.argv[1]), ""))' "$p")+ if [ "$ws" != "$p" ]; then+ echo "modal: profile $p reaches workspace ${ws:-none}, not $p"+ return 2+ fi+ # a new workspace builds images with Modal's newest builder, which this machine's client (1.5.2) can't speak; 2025.06+ # is the newest it can, and what the farm was measured on+ export MODAL_IMAGE_BUILDER_VERSION=${MODAL_IMAGE_BUILDER_VERSION:-2025.06}+ denied=$(git -C "$(dirname "${BASH_SOURCE[0]}")" rev-parse --show-toplevel 2>/dev/null)/private/cloud/modal-denied.txt+ if [ -f "$denied" ] && grep -qxF "$ws" "$denied"; then+ echo "modal: $ws belongs to another business ($denied)"+ return 2+ fi+}diff --git a/sdk/cloud/deploy/modal/models.sh b/sdk/cloud/deploy/modal/models.shindex 5f4b0f53..1bfe5ccd 100755--- a/sdk/cloud/deploy/modal/models.sh+++ b/sdk/cloud/deploy/modal/models.sh@@ -2,7 +2,7 @@# The models raea runs on Linux, from this Mac into the Modal volume raea-models (docs/cloud-render.md, "Models"), for# the farm's GPUs and a cloud box to mount instead of fetching them on each cold start:#-# MODAL_PROFILE=shane-25168 deploy/modal/models.sh # stage and upload+# MODAL_PROFILE=raea deploy/modal/models.sh # stage and upload# deploy/modal/models.sh --dry # stage only, and list what would go## /raea perception's folder (RAEA_MODELS): the ONNX and data files no public source serves as raea runs them;@@ -60,7 +60,8 @@ find "$stage" \( -name '*.mlpackage' -o -name '*.mlmodelc' -o -name coreml -o -ndu -sh "$stage"/* | sed "s|$stage/||"[ "$dry" = --dry ] && { find "$stage" -type f | sed "s|$stage/||" | sort; exit 0; }-[ "${MODAL_PROFILE:-}" = shane-25168 ] || { echo "models: run with MODAL_PROFILE=shane-25168 (raea's own Modal workspace)"; exit 2; }+. "$(dirname "$0")/guard.sh"+modal_guardmodal volume create raea-models --version 2 2>/dev/null || truefor top in raea feed library; do[ -d "$stage/$top" ] && modal volume put --force raea-models "$stage/$top" "/$top"diff --git a/sdk/cloud/deploy/modal/weights.py b/sdk/cloud/deploy/modal/weights.pynew file mode 100644index 00000000..560bd574--- /dev/null+++ b/sdk/cloud/deploy/modal/weights.py@@ -0,0 +1,40 @@+# A Hugging Face repo's files into a Modal volume, fetched inside Modal so nothing goes through this machine+# (docs/cloud-render.feature CR20). From sdk/cloud:+# RAEA_WEIGHTS_VOLUME=raea-headgen-weights MODAL_PROFILE=raea modal run deploy/modal/weights.py --repo VAST-AI/TripoSG --dest TripoSG+# It prints a line every 30 s while it fetches, so a watcher can tell it's alive.++import os+import threading++import modal++VOLUME = os.environ.get("RAEA_WEIGHTS_VOLUME", "raea-headgen-weights")+vol = modal.Volume.from_name(VOLUME, create_if_missing=True)+app = modal.App("raea-weights", image=modal.Image.debian_slim(python_version="3.12").pip_install("huggingface_hub==0.35.3"))+++def size(path):+ return sum(os.path.getsize(os.path.join(d, f)) for d, _, fs in os.walk(path) for f in fs)++[email protected](volumes={"/vol": vol}, timeout=3600, cpu=2)+def fetch(repo: str, dest: str, revision: str = "main") -> str:+ from huggingface_hub import snapshot_download++ out = f"/vol/{dest}"+ done = threading.Event()++ def beat():+ while not done.wait(30):+ print(f"weights: {size(out) / 1e9:.2f} GB of {repo} so far", flush=True) if os.path.isdir(out) else None++ threading.Thread(target=beat, daemon=True).start()+ snapshot_download(repo, revision=revision, local_dir=out)+ done.set()+ vol.commit()+ return f"weights: {repo}@{revision} in {VOLUME}:/{dest}, {size(out) / 1e9:.2f} GB"++[email protected]_entrypoint()+def main(repo: str, dest: str, revision: str = "main"):+ print(fetch.remote(repo, dest, revision))diff --git a/sdk/cloud/deploy/modal/workspace.sh b/sdk/cloud/deploy/modal/workspace.shnew file mode 100755index 00000000..91f15863--- /dev/null+++ b/sdk/cloud/deploy/modal/workspace.sh@@ -0,0 +1,88 @@+#!/bin/bash+# raea's Modal apps in one workspace, made from nothing (docs/cloud-render.feature CR20). From sdk/cloud:+#+# MODAL_PROFILE=raea deploy/modal/workspace.sh secrets, volumes, weights and the apps, each one checked+# MODAL_PROFILE=raea deploy/modal/workspace.sh check the apps' health only+#+# What it makes in the workspace: the secrets raea-farm (a new token) and raea-made (MADE_API_KEY from ~/.raea/env);+# the volume raea-models (models.sh); TripoSG in raea-headgen-weights, fetched inside Modal (weights.py); and the apps+# raea-farm, raea-step and raea-comfy (CPU). Their URLs go in ~/.config/raea-cloud/modal-PROFILE.env. On this machine,+# once each answers, ~/.config/raea-cloud/farm.env names the new farm and ~/.raea/env's RAEA_MODAL_UPSCALE the new+# raea-step. ComfyUI weights a workflow needs go in with `modal run tools/comfy/modal_comfy.py::needs` (gen.feature).+set -euo pipefail+cd "$(dirname "$0")/../.."+. deploy/modal/guard.sh+modal_guard+P=$MODAL_PROFILE+ROOT=$(git rev-parse --show-toplevel)+ENVF=${RAEA_ENV_FILE:-$HOME/.raea/env}+CONF=$HOME/.config/raea-cloud+URLS=$CONF/modal-$P.env+tmp=$(mktemp -d)+trap 'rm -rf "${tmp:?}"' EXIT+mkdir -p "$CONF"++say() { echo "workspace $P: $*"; }+# a deploy's first web URL in this workspace+deploy() {+ local out+ out=$(modal deploy "$@" 2>&1) || { echo "$out" | tail -20; return 1; }+ echo "$out" | grep -oE "https://$P--[a-z0-9-]+(\.[a-z0-9-]+)*\.modal\.run" | head -1+}+# KEY=VALUE into a file only this user reads+keep() { (umask 077 && touch "$1" && { grep -v "^$2=" "$1" >"$1.new" || true; } && echo "$2=$3" >>"$1.new" && mv "$1.new" "$1"); }++check() {+ local ok=0 farm step comfy png+ [ -f "$URLS" ] || { say "nothing deployed yet ($URLS)"; return 1; }+ farm=$(sed -n 's/^RAEA_FARM_URL=//p' "$URLS")+ step=$(sed -n 's/^RAEA_STEP_URL=//p' "$URLS")+ comfy=$(sed -n 's/^RAEA_COMFY_URL=//p' "$URLS")+ if curl -fsS -m 120 "$farm/healthz" >/dev/null; then say "raea-farm answers at $farm"; else say "raea-farm doesn't answer"; ok=1; fi+ # a 2x2 PNG through image.upscale: the contract io/gen/src/modal.rs speaks+ png=$(ffmpeg -loglevel error -f lavfi -i color=c=gray:s=2x2 -frames:v 1 -f image2pipe -vcodec png - | base64 | tr -d '\n')+ if curl -fsS -m 300 -H 'content-type: application/json' -d "{\"op\":\"image.upscale\",\"inputs\":{\"image\":\"data:image/png;base64,$png\",\"factor\":2}}" "$step" | grep -q '"files"'; then+ say "raea-step upscales at $step"+ else+ say "raea-step doesn't answer"+ ok=1+ fi+ if curl -fsS -m 600 "$comfy/system_stats" | grep -q comfyui_version; then say "raea-comfy answers at $comfy"; else say "raea-comfy doesn't answer"; ok=1; fi+ return $ok+}++if [ "${1:-}" = check ]; then+ check+ exit $?+fi++# secrets: a new farm token; made.app's key from this machine's raea settings, never printed+T=$(openssl rand -hex 32)+(umask 077 && echo "RAEA_CLOUD_TOKEN=$T" >"$tmp/farm.env")+modal secret create --force raea-farm --from-dotenv "$tmp/farm.env" >/dev/null+K=$(sed -n 's/^MADE_API_KEY=//p' "$ENVF" 2>/dev/null | tail -1)+if [ -n "$K" ]; then+ (umask 077 && echo "MADE_API_KEY=$K" >"$tmp/made.env")+ modal secret create --force raea-made --from-dotenv "$tmp/made.env" >/dev/null+else+ say "no MADE_API_KEY in $ENVF, so raea-comfy goes up without made.app's nodes"+ export RAEA_MADE_SECRET=0+fi+say "secrets raea-farm and raea-made set"++# raea's models (once: models.sh uploads them again on its own), and the head generator's weights (fetched inside Modal)+if modal volume ls raea-models /raea 2>/dev/null | grep -q .; then say "raea-models already holds raea's models"; else deploy/modal/models.sh; fi+RAEA_WEIGHTS_VOLUME=raea-headgen-weights modal run deploy/modal/weights.py --repo VAST-AI/TripoSG --dest TripoSG 2>&1 | grep --line-buffered -E "^weights:|rror"++# the apps+farm=$(deploy deploy/modal/farm.py)+step=$(deploy "$ROOT/tools/comfy/modal_step.py")+comfy=$(deploy "$ROOT/tools/comfy/modal_comfy.py")+for kv in "RAEA_FARM_URL=$farm" "RAEA_STEP_URL=$step" "RAEA_COMFY_URL=$comfy"; do keep "$URLS" "${kv%%=*}" "${kv#*=}"; done+say "deployed: $farm, $step, $comfy"++check || { say "not everything answers, so this machine still points at the old ones"; exit 1; }+keep "$CONF/farm.env" RAEA_CLOUD_GPU_URL "$farm"+keep "$CONF/farm.env" RAEA_CLOUD_GPU_TOKEN "$T"+keep "$ENVF" RAEA_MODAL_UPSCALE "$step"+say "this machine now renders on $farm and upscales on $step"