|
|
||
|---|---|---|
| custom_nodes/comfy-vast-fixups | ||
| .gitignore | ||
| civitai-get | ||
| comfy-deps | ||
| comfy-endpoint | ||
| comfy-fetch-models | ||
| comfy-wrapper-patch | ||
| provision.sh | ||
| README.md | ||
| ws-autopush | ||
| ws-env.sh | ||
| ws-excludes.txt | ||
| ws-live | ||
| ws-pull | ||
| ws-push | ||
comfy-vast — the instance kit
Scripts that turn a Vast.ai instance running the stock vastai/comfy image into a ready ComfyUI
box: pull the workspace from an R2 bucket, install what the venv is missing, patch two things the
image gets wrong, push new material back, and publish annotated workflows as endpoints for the
sibling project Comfy Vast Studio (the laptop page that runs them). The repository is cloned
onto every instance as /root/tools.
Pieces
| Script | Does |
|---|---|
provision.sh |
Vast's provisioning script: clone/pull this repo (+ aria2, inotify-tools), ws-pull, install the fixups symlink, comfy-deps, comfy-wrapper-patch, start ws-autopush and ws-live |
ws-env.sh |
rclone remote from the template env, WS_* defaults, the filter builder |
ws-pull |
bucket → /workspace, add/update only; selective with WS_WORKFLOWS (below) |
ws-push |
/workspace → bucket, add/update only, never deletes (--mirror does, after a dry run and a prompt) |
ws-autopush |
ws-push every WS_PUSH_INTERVAL seconds (600) |
ws-live |
the mount's stand-in for ComfyUI/user (a Vast container cannot mount: no /dev/fuse, no CAP_SYS_ADMIN): every change under user/ is pushed within ~1 s (inotify; deletes included, a deleted folder is purged), and the bucket's user/ is pulled every 20 s with newer-wins. Workflows saved in the editor, endpoints converted on the laptop and published sidecars therefore meet within seconds |
comfy-deps |
pip install every pack's requirements into /venv/main, update Manager, restart ComfyUI |
comfy-fetch-models |
the models a workflow references → download or resolve against a bucket listing |
civitai-get |
Civitai URL/id → the right models/ subfolder |
comfy-endpoint |
annotated editor workflow → Studio endpoint (API format) + .source sidecar |
comfy-wrapper-patch |
adds the missing comfyui_job_id field to the API wrapper's Result model and restarts it |
custom_nodes/comfy-vast-fixups |
node-less pack that re-enables comfy_kitchen's CUDA backend (ComfyUI disables it below cu130; Ref2VA-VSA needs it) |
Template env (Vast): RCLONE_CONFIG_R2_ACCESS_KEY_ID, RCLONE_CONFIG_R2_SECRET_ACCESS_KEY,
RCLONE_CONFIG_R2_ENDPOINT, TOOLS_REPO (HTTPS clone URL of this repo), PROVISIONING_SCRIPT
(raw URL of provision.sh), CIVITAI_TOKEN; optional WS_REMOTE, WS_WORKFLOWS, WS_INCLUDE.
Selective provisioning: WS_WORKFLOWS
With WS_WORKFLOWS="H3_LongTake_i2v.studio,ref2va_vsa.studio" (names under workflows/, .json
implied, globs allowed) a pull fetches:
- all of
user/(every base workflow, every endpoint's.sourcesidecar, settings), allcustom_nodes/,models/ultralytics/, plus anyWS_INCLUDEglobs; - the models the named base workflows reference;
- only the endpoints whose
.sourceline 1 names one of those bases (an endpoint without a sidecar is pulled when its file name matches a pattern), and - the extra models listed on those sidecars' lines 2+.
Endpoints whose models were not pulled therefore never appear in the Studio. All bases are always
pulled, so WS_WORKFLOWS="other" ws-pull on a running box extends it with another base, its models
and its endpoint. A plain ws-pull fetches everything.
The sidecar endpoints/<name>.source:
H3_LongTake_i2v.studio.json # line 1: the base workflow, relative to user/default/workflows/
loras/H3_*.safetensors # lines 2+: extra models the endpoint needs, relative to ComfyUI/models/
unet/alternative.safetensors # globs allowed, blank lines and # comments ignored
comfy-endpoint writes line 1 (and rewrites only line 1 on a reconvert); the lines below are
yours. comfy-endpoint --set-source "<Endpoint>" <base> writes line 1 for an endpoint made by hand.
The Studio's Publish adds blocks of its own for presets, # preset: <name> … # end preset: <name>,
and only ever rewrites those; a file it cannot find in the bucket is written as # not in bucket: ….
Repeated paths across blocks are fine: the pull de-duplicates.
Manual: preparing a workflow for the converter
The Studio runs endpoints: API-format prompts with markers that say which values the page exposes. You make one from an ordinary editor workflow in three steps, all on the instance.
1. Make the workflow conform, in the editor
- Fixed values are values: set them (e.g.
dry_run = false) and leave them unmarked. - Ctrl+M / Ctrl+B are not inputs. A node that should be switchable from the page gets a
{switch:name}marker (its mute state becomes the default); a node left muted without a switch is simply left out; a bypassed node without a switch or?marker is refused. - Results must either come out of a saver node (type
{out:video}or{out:image}into its filename prefix field) or from a node that reports its own saved files (the H3 LongTake nodes do). - A widget that was converted to an input (fed by a link) cannot be marked; disconnect it or
mark the node that feeds it. Nodes that read the editor's graph (
WidgetToString) must go. - If the file came as an API-format JSON (flat
{"id": {"class_type", "inputs"}}, nonodesarray), drop it on the canvas first; the frontend rebuilds a graph; check the links it recreated.
2. Annotate node titles
Append markers to the node's title (everything else in the title stays; several markers per title):
| Marker | Meaning |
|---|---|
{in:duration@duration_seconds} |
expose this widget; its current value is the default; the page renders it from the node's spec (slider, toggle, dropdown, textarea) |
{in:duration@duration_seconds[1..30:0.5]} |
same, with the slider's range (INT/FLOAT only; [min..max] or [min..max:step]; the default must lie inside) |
{in:clip_duration@clip_frames[22..362:17 s/24]} |
same, shown and edited as raw ÷ 24 in "s" (any unit, any divisor); the page snaps to the step and sends the raw value, so a frame count reads as a duration |
{in:clips@duration_seconds[1..8 = (clips*(clip_duration-5)+5)/24]} |
a derived input: the page shows clips (1–8, step 1 unless given) and the widget receives the expression, evaluated at run time over the form's other inputs in their raw units (+ - * / and parentheses; every name must be an input of the endpoint). The live result shows beside the control; the sidecar records it under derived |
{in:prompt@prompts} |
a text widget: exposed, its text is stripped on publish |
{in:start@image} on a LoadImage |
an image input |
{in:face?@image} on a LoadImage |
an optional image: a job without it removes the node and leaves the consumer's input unconnected |
{switch:refine} |
a toggle for this node; off = the node and everything downstream are left out |
{in:loras} on a LoRA node |
the job's LoRA list replaces it (added automatically when missing) |
{in:audio_vae@vae_name} on a loader |
names a model dropdown (otherwise auto-named after the field: unet, clip, vae, vae_2, gate_file …) |
{out:video} in a saver's prefix field |
a result |
| same name on two nodes | one control feeds both |
Reserved names: seed, seeds, overrides, preset. Seeds need nothing: every seed/noise_seed
is randomised per job unless the page gives one. Save the workflow as <name>.studio.json.
3. Convert
comfy-endpoint <name>.studio --name "Readable Endpoint Name" # writes endpoints/<Name>.json + .source
comfy-endpoint <name>.studio --name "…" --dry-run # report only
comfy-endpoint <name>.studio --name "…" --force # reconvert after editing the base
comfy-endpoint <path> --name "…" --out <endpoints dir> --object-info URL|FILE # from a laptop: pass paths, and a
# ComfyUI /object_info to bake full specs
On the instance the script finds ComfyUI itself and bakes full control specs. On the laptop (the
Studio mounts the bucket's workflows/ at ./workflows and wraps this script as comfy-endpoint,
with --instance <id> to reach a connected instance's ComfyUI) specs are coarse unless
--object-info points at a server or a saved file; ws-live on the instance picks the result up
within seconds.
The report lists every control with its kind and default, what was stripped, and how many nodes the endpoint has. Every problem is reported at once; fix them in the editor and rerun. One known message: "cannot locate the value of 'x' in widgets_values … save it again" means the node pack added a widget since the file was saved; open and save the workflow in the editor to rebuild it. Autopush carries the endpoint and sidecar to the bucket; in the Studio press ↻ Refresh.
What the converter does for you
Model-file dropdowns become {in:…} slots (the endpoint carries no model names), LoRA entries are
emptied, text slots blanked, Markdown/Note nodes dropped, widget values mapped through the editor's
own inputs list (the image's converter pack mis-assigns them after link-only inputs), reroutes
followed, muted nodes left out, and the result written in API format next to the .source sidecar.
Each exposed widget's control spec (type, min/max/step, the options of non-model combos) is baked
into the node's _meta.studio from ComfyUI's /object_info when a server is reachable (on the instance,
or --object-info URL|FILE); converting on the laptop without one bakes coarse types, and a later
reconvert on an instance upgrades them. Model-file lists are never baked.
Things the image gets wrong (and the kit fixes)
- The API wrapper's
Resultmodel lackscomfyui_job_id; any prompt ComfyUI rejects instantly surfaces as a pydantic error instead of the cause.comfy-wrapper-patch. - ComfyUI 0.40 disables comfy_kitchen's CUDA backend when PyTorch is built against CUDA < 13 (the
image is cu128); packs that require it fail with
Backend 'cuda' is not available: disabled.custom_nodes/comfy-vast-fixups, symlinked byprovision.sh. The durable alternative is a cu130 torch in/venv/main. - The wrapper inlines outputs as base64 only up to 10 MB and its progress stream rides a Cloudflare
quick tunnel that drops after ~100 s of silence; the Studio downloads big results from ComfyUI's
/viewand polls/resultafter a drop.