mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 21:03:47 -10:00
deploy/login.sh gives a machine a Modal profile for the raea workspace (never made the default; a token that reaches any other workspace is removed at once) and a Sprites token for the raea Fly org, read from the clipboard so it is never typed, and writes the org where deploy/sprites/box.sh reads it. deploy/modal/guard.sh is the one check every Modal script makes: the profile reaches the workspace of its own name and none listed under private/cloud, with image builder 2025.06, the newest this client builds. deploy/modal/workspace.sh makes the workspace from nothing: the farm and made.app secrets, raea's models (once), TripoSG fetched inside Modal (deploy/modal/weights.py), and raea-farm, raea-step and raea-comfy; it repoints this machine's farm and upscale settings only after the farm answers, raea-step upscales a picture and ComfyUI reports its version. The usage lines now name the raea profile. Checked: workspace.sh built the raea workspace and all three apps answered; test/farm.ts rendered edit.tsx there, 90 frames at 1080p on an A10 in 77 s, billed about $0.024; the guard refused an unset profile, a missing one and a denied one, and a wrongly approved profile was removed from a sample config.
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
# 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)
|
|
|
|
|
|
@app.function(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"
|
|
|
|
|
|
@app.local_entrypoint()
|
|
def main(repo: str, dest: str, revision: str = "main"):
|
|
print(fetch.remote(repo, dest, revision))
|