renderboy 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/renderboy.js +140 -53
- package/package.json +1 -1
package/dist/renderboy.js
CHANGED
|
@@ -2,18 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
// ../shared/limits.ts
|
|
4
4
|
var RATE_USD_PER_GPU_HOUR = 2.5;
|
|
5
|
-
var
|
|
5
|
+
var MIN_CHARGE_PER_GPU_USD = 0.025;
|
|
6
|
+
var DEFAULT_GPUS = 4;
|
|
6
7
|
var DEFAULT_MAX_SPEND_USD = 5;
|
|
7
8
|
var MACHINE = { gpu: "NVIDIA RTX 4090", vramGb: 24, ramGb: 32 };
|
|
8
9
|
var MAX_FRAMES = 2e4;
|
|
9
10
|
var MAX_FRAME_NUMBER = 1048574;
|
|
10
11
|
var MAX_UPLOAD_BYTES = 5e9;
|
|
12
|
+
var MAX_CONTACT_SHEET_BYTES = 64 * 1024 * 1024;
|
|
11
13
|
|
|
12
14
|
// ../shared/help.ts
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
15
|
+
var moneyText = (usd3) => Number.isInteger(Math.round(usd3 * 1e6) / 1e4) ? `$${usd3.toFixed(2)}` : `${Math.round(usd3 * 1e4) / 100}\xA2`;
|
|
16
|
+
var MINIMUM_PER_GPU = `${moneyText(MIN_CHARGE_PER_GPU_USD)} per GPU`;
|
|
17
|
+
var PRICE = `$${RATE_USD_PER_GPU_HOUR.toFixed(2)} per GPU-hour of frame rendering, billed per second, plus a minimum of ${MINIMUM_PER_GPU} the job can use (${moneyText(MIN_CHARGE_PER_GPU_USD * DEFAULT_GPUS)} on the default ${DEFAULT_GPUS})`;
|
|
18
|
+
var CAP = `default: ${moneyText(DEFAULT_MAX_SPEND_USD)}, or your spare credit if less`;
|
|
19
|
+
var DEFAULT_CAP = `at least the job's minimum (${CAP})`;
|
|
17
20
|
var ERRORS = "Every error is one line `error CODE: message` and then `fix: ...` on stderr: do what the fix says. Results and the render's progress go to stdout; problems and the progress of the local steps (checking, baking, uploading) to stderr.";
|
|
18
21
|
var EXIT_CODES = "0 done, 1 the job failed or was cancelled, 2 usage, 3 the local check found problems, 4 credit or spend cap, 5 network or API error, 130 interrupted (a render only detaches: the job renders on).";
|
|
19
22
|
var CANCEL_WITHOUT_JOB = "Without JOB: the one job running; with several running it lists them and asks for one (exit 2); with none it says so (exit 0).";
|
|
@@ -27,6 +30,7 @@ var SKILL_APPS = [
|
|
|
27
30
|
];
|
|
28
31
|
var listed = (names, and = "and") => names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} ${and} ${names[names.length - 1]}`;
|
|
29
32
|
var skillInstall = (app) => `renderboy skill install ${app}`;
|
|
33
|
+
var SKILL_INSTALL_ANY = { command: "renderboy skill install APP", apps: listed(SKILL_APPS.map(([app]) => app), "or") };
|
|
30
34
|
var HELP = {
|
|
31
35
|
intro: "RenderBoy renders a saved .blend on cloud GPUs (RTX 4090, Cycles) and brings the frames, an MP4 and a contact sheet back. Build and preview the scene on this machine with Blender 5.2, for free; `renderboy render` checks, bakes and packs it with that Blender, uploads one file, renders its frames on the farm and downloads them.",
|
|
32
36
|
start: [
|
|
@@ -60,12 +64,12 @@ var HELP = {
|
|
|
60
64
|
["skill", "install the skill that tells a coding agent about renderboy"]
|
|
61
65
|
],
|
|
62
66
|
render: {
|
|
63
|
-
description: "Render FILE.blend on cloud GPUs and download the result. In order: check the scene with the local Blender 5.2; bake its simulations and pack every file it uses into one .blend (a copy: your file is never changed); upload it (skipped when the account holds it already); render the frames on --gpus GPUs; download them as they finish; then
|
|
67
|
+
description: "Render FILE.blend on cloud GPUs and download the result. In order: check the scene with the local Blender 5.2; bake its simulations and pack every file it uses into one .blend (a copy: your file is never changed); upload it (skipped when the account holds it already); render the frames on --gpus GPUs; download them as they finish; then download video.mp4 and contact_sheet.png, which the farm makes of an animation, or make them here when it has none. Run it with a long timeout or in the background: a render can take a while.",
|
|
64
68
|
file: "the saved scene (unsaved changes in an open Blender are not seen)",
|
|
65
69
|
options: [
|
|
66
70
|
["--max-spend", "USD", `the most the job may cost, ${DEFAULT_CAP}`],
|
|
67
71
|
["--frames", "SPEC", "1-250, 1-250:2 (every 2nd), 1,125,250 or a mix; one number is a still (default: the scene's range and step)"],
|
|
68
|
-
["--gpus", "N", "GPUs rendering at once (default: 4, at most the farm's limit): more finish sooner
|
|
72
|
+
["--gpus", "N", "GPUs rendering at once (default: 4, at most the farm's limit): more finish sooner at the same rate; the minimum is per GPU"],
|
|
69
73
|
["--json", null, "print one JSON document at the end instead of lines"]
|
|
70
74
|
],
|
|
71
75
|
scene: [
|
|
@@ -77,7 +81,7 @@ var HELP = {
|
|
|
77
81
|
"A scene set to write a movie renders PNG frames: the video is made here.",
|
|
78
82
|
"Try a few frames first (--frames 1,120,240) and look at them."
|
|
79
83
|
],
|
|
80
|
-
cost: `${PRICE}
|
|
84
|
+
cost: `${PRICE}; the rate is the same whatever --gpus is. Rendering stops before the next frame would pass --max-spend (SPEND_CAP_REACHED, exit 4): run the same command with a higher cap to render the rest. A job that fails or is cancelled before its first frame is stored costs nothing. After that, a frame that fails because of the scene (out of memory, a crash) is billed for the time it used and ends the job.`,
|
|
81
85
|
outputWhere: "In FILE_render/ in the current directory (scene_render/ for scene.blend); the last lines print the absolute paths.",
|
|
82
86
|
outputs: [
|
|
83
87
|
["frames/0001.png ...", "the frames by number, in the scene's image format"],
|
|
@@ -141,7 +145,7 @@ var CLI_FIXES = {
|
|
|
141
145
|
ADDON_REQUIRED: "Apply or bake what the add-on generates, then save.",
|
|
142
146
|
BAKE_FAILED: "Bake it in Blender to see the error, fix it and save.",
|
|
143
147
|
PACK_FAILED: "Run `blender -b {file}` to see Blender's own error, then try again.",
|
|
144
|
-
SPEND_CAP_TOO_LOW: `Set \`--max-spend\` to at least ${
|
|
148
|
+
SPEND_CAP_TOO_LOW: `Set \`--max-spend\` to at least the job's minimum, ${MINIMUM_PER_GPU} it can use: ${(MIN_CHARGE_PER_GPU_USD * DEFAULT_GPUS).toFixed(2)} on the default ${DEFAULT_GPUS}.`,
|
|
145
149
|
ENCODE_FAILED: "The frames are in the folder; run the same command again to try the video once more.",
|
|
146
150
|
BAD_UPLOAD: "Run the same command again: the CLI uploads the file again.",
|
|
147
151
|
CANCELLED: "Run the same command again to render the rest: finished frames are kept.",
|
|
@@ -188,8 +192,6 @@ function exitCode(code, fallback) {
|
|
|
188
192
|
if (code === "ENCODE_FAILED") return EXIT_FAILED;
|
|
189
193
|
return fallback;
|
|
190
194
|
}
|
|
191
|
-
var UsageError = class extends Error {
|
|
192
|
-
};
|
|
193
195
|
var Interrupted = class extends Error {
|
|
194
196
|
constructor() {
|
|
195
197
|
super("interrupted");
|
|
@@ -222,6 +224,11 @@ var Problem = class extends Error {
|
|
|
222
224
|
}
|
|
223
225
|
};
|
|
224
226
|
var retryableStatus = (status) => status === 429 || status >= 500 && status < 600 && status !== 501 && status !== 505;
|
|
227
|
+
var UsageError = class extends Problem {
|
|
228
|
+
constructor(message, fix) {
|
|
229
|
+
super("BAD_USAGE", message, fix, { exit: EXIT_USAGE });
|
|
230
|
+
}
|
|
231
|
+
};
|
|
225
232
|
|
|
226
233
|
// src/clock.ts
|
|
227
234
|
var waiting = /* @__PURE__ */ new Set();
|
|
@@ -697,7 +704,7 @@ var fill = (text2, width, options = {}) => wrap(text2, width, options).join("\n"
|
|
|
697
704
|
var LINE_BREAKS = new RegExp("\\r\\n|[\\n\\r\\x0b\\x0c\\x1c\\x1d\\x1e\\x85\\u2028\\u2029]");
|
|
698
705
|
|
|
699
706
|
// src/version.ts
|
|
700
|
-
var VERSION = "0.7.
|
|
707
|
+
var VERSION = "0.7.3";
|
|
701
708
|
var USER_AGENT = `renderboy/${VERSION}`;
|
|
702
709
|
|
|
703
710
|
// src/api.ts
|
|
@@ -756,7 +763,9 @@ var Api = class {
|
|
|
756
763
|
transport;
|
|
757
764
|
http = new Client(USER_AGENT);
|
|
758
765
|
constructor(baseUrl, key = null, keySource = null) {
|
|
759
|
-
if (!/^https?:\/\//.test(baseUrl))
|
|
766
|
+
if (!/^https?:\/\//.test(baseUrl)) {
|
|
767
|
+
throw new UsageError(`The API address must start with https:// (RENDERBOY_API is ${quoted(baseUrl)}).`, "Set RENDERBOY_API to the API's https:// address, or unset it for https://api.renderboy.dev.");
|
|
768
|
+
}
|
|
760
769
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
761
770
|
this.keySource = key ? keySource : null;
|
|
762
771
|
this.headers = { Accept: "application/json", "Accept-Encoding": "gzip" };
|
|
@@ -2368,9 +2377,12 @@ Request: {"result", "what": "video" | "sheet", "frames": [[number, path], ...] (
|
|
|
2368
2377
|
|
|
2369
2378
|
The video is H.264 in MP4, silent, at constant quality: Blender's "perceptually lossless" (CRF
|
|
2370
2379
|
17), x264's medium preset, B-frames, a keyframe every 2 seconds; each frame is held until the next
|
|
2371
|
-
one there is. The sheet
|
|
2372
|
-
wide, each labelled with its frame number. 8-bit frames go
|
|
2373
|
-
get the scene's view transform, look and exposure.
|
|
2380
|
+
one there is. The sheet picks up to 12 of the frames, evenly spaced, and lays them out
|
|
2381
|
+
(sheet_layout) in a grid at most 2048 px wide, each labelled with its frame number. 8-bit frames go
|
|
2382
|
+
in as they are; scene-linear frames get the scene's view transform, look and exposure.
|
|
2383
|
+
|
|
2384
|
+
The farm's encode task runs a copy of this file (worker/bf_worker/bpy_scripts/cli_encode.py, which
|
|
2385
|
+
a test keeps identical), so a job's video and contact sheet are the same whoever makes them.
|
|
2374
2386
|
"""
|
|
2375
2387
|
|
|
2376
2388
|
import math
|
|
@@ -2384,7 +2396,27 @@ import common # noqa: E402
|
|
|
2384
2396
|
from common import Failure # noqa: E402
|
|
2385
2397
|
|
|
2386
2398
|
SHEET_WIDTH = 2048
|
|
2387
|
-
SHEET_FRAMES = 12
|
|
2399
|
+
SHEET_FRAMES = 12 # the contact sheet's most frames
|
|
2400
|
+
SHEET_COLUMNS = 4 # and its most columns
|
|
2401
|
+
|
|
2402
|
+
|
|
2403
|
+
def sheet_layout(frames):
|
|
2404
|
+
"""The contact sheet's grid: up to 12 evenly spaced frames (the first and the last among them),
|
|
2405
|
+
up to 4 a row, in order; a last row they don't fill has its frames centred, its cells half a
|
|
2406
|
+
cell in for each empty cell. Returns (cols, rows, [(frame, col, row), ...])."""
|
|
2407
|
+
count = min(SHEET_FRAMES, len(frames))
|
|
2408
|
+
if count > 1:
|
|
2409
|
+
picked = [frames[math.floor((i * (len(frames) - 1)) / (count - 1) + 0.5)] for i in range(count)]
|
|
2410
|
+
else:
|
|
2411
|
+
picked = list(frames[:1])
|
|
2412
|
+
cols = min(SHEET_COLUMNS, count)
|
|
2413
|
+
rows = math.ceil(count / cols)
|
|
2414
|
+
last = count - (rows - 1) * cols
|
|
2415
|
+
cells = []
|
|
2416
|
+
for i, frame in enumerate(picked):
|
|
2417
|
+
row = i // cols
|
|
2418
|
+
cells.append((frame, (i % cols) + ((cols - last) / 2 if row == rows - 1 else 0), row))
|
|
2419
|
+
return cols, rows, cells
|
|
2388
2420
|
|
|
2389
2421
|
|
|
2390
2422
|
def new_scene(request):
|
|
@@ -2450,21 +2482,18 @@ def video(request, scene, editor, frames):
|
|
|
2450
2482
|
|
|
2451
2483
|
|
|
2452
2484
|
def sheet(request, scene, editor, frames):
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
width, height = image_size(picked[0][1])
|
|
2456
|
-
cols = min(4, count)
|
|
2457
|
-
rows = math.ceil(count / cols)
|
|
2485
|
+
cols, rows, cells = sheet_layout(frames)
|
|
2486
|
+
width, height = image_size(cells[0][0][1])
|
|
2458
2487
|
cell_w = min(width, SHEET_WIDTH // cols)
|
|
2459
2488
|
cell_h = max(1, round(cell_w * height / width))
|
|
2460
2489
|
total_w, total_h = cols * cell_w, rows * cell_h
|
|
2461
2490
|
font = max(12, cell_h // 10)
|
|
2462
2491
|
margin = max(2, font // 4)
|
|
2463
|
-
for
|
|
2464
|
-
|
|
2492
|
+
for (number, path), col, row in cells:
|
|
2493
|
+
left = round(col * cell_w) # a centred last row's cells are half a cell in: on whole pixels
|
|
2465
2494
|
strip = editor.strips.new_image(f"f{number}", path, 2, 1, fit_method="ORIGINAL")
|
|
2466
2495
|
strip.transform.scale_x = strip.transform.scale_y = cell_w / width
|
|
2467
|
-
strip.transform.offset_x =
|
|
2496
|
+
strip.transform.offset_x = left + cell_w / 2 - total_w / 2
|
|
2468
2497
|
strip.transform.offset_y = total_h / 2 - (row * cell_h + cell_h / 2)
|
|
2469
2498
|
text = editor.strips.new_effect(f"t{number}", "TEXT", 3, 1, length=1)
|
|
2470
2499
|
text.text = str(number)
|
|
@@ -2472,7 +2501,7 @@ def sheet(request, scene, editor, frames):
|
|
|
2472
2501
|
text.use_box = True
|
|
2473
2502
|
text.anchor_x, text.anchor_y = "LEFT", "BOTTOM"
|
|
2474
2503
|
text.box_margin = margin / total_w # a factor of the sheet's width
|
|
2475
|
-
text.location = ((
|
|
2504
|
+
text.location = ((left + 2 * margin) / total_w, 1 - ((row + 1) * cell_h - 2 * margin) / total_h)
|
|
2476
2505
|
r = scene.render
|
|
2477
2506
|
r.resolution_x, r.resolution_y, r.resolution_percentage = total_w, total_h, 100
|
|
2478
2507
|
scene.frame_start = scene.frame_end = 1
|
|
@@ -3040,7 +3069,7 @@ async function poll(anon, login) {
|
|
|
3040
3069
|
} catch (err2) {
|
|
3041
3070
|
if (!(err2 instanceof Problem)) throw err2;
|
|
3042
3071
|
if (err2.code === "ACCESS_DENIED") return new Problem("ACCESS_DENIED", "The sign-in was denied in the browser.", "Run `renderboy login` again and choose Approve in the browser.");
|
|
3043
|
-
if (err2.code === "EXPIRED_TOKEN") return
|
|
3072
|
+
if (err2.code === "EXPIRED_TOKEN") return err2;
|
|
3044
3073
|
if (err2.code === "RATE_LIMITED") {
|
|
3045
3074
|
interval += RATE_LIMIT_PENALTY;
|
|
3046
3075
|
continue;
|
|
@@ -3167,15 +3196,17 @@ import tty2 from "node:tty";
|
|
|
3167
3196
|
var BadValue = class extends Error {
|
|
3168
3197
|
};
|
|
3169
3198
|
var ParseExit = class extends Error {
|
|
3170
|
-
constructor(code, out, err2) {
|
|
3199
|
+
constructor(code, out, err2, problem = null) {
|
|
3171
3200
|
super("exit");
|
|
3172
3201
|
this.code = code;
|
|
3173
3202
|
this.out = out;
|
|
3174
3203
|
this.err = err2;
|
|
3204
|
+
this.problem = problem;
|
|
3175
3205
|
}
|
|
3176
3206
|
code;
|
|
3177
3207
|
out;
|
|
3178
3208
|
err;
|
|
3209
|
+
problem;
|
|
3179
3210
|
};
|
|
3180
3211
|
var ArgumentError = class extends Error {
|
|
3181
3212
|
constructor(action, message) {
|
|
@@ -3227,9 +3258,12 @@ var Parser = class {
|
|
|
3227
3258
|
if (all.length) this.fail(`unrecognized arguments: ${all.join(" ")}`);
|
|
3228
3259
|
return values;
|
|
3229
3260
|
}
|
|
3261
|
+
/** A usage error: the usage line, then the error and its fix as every error of the CLI says them. */
|
|
3230
3262
|
fail(message) {
|
|
3231
|
-
|
|
3232
|
-
|
|
3263
|
+
const fix = `Run \`${this.prog} --help\` for what it takes.`;
|
|
3264
|
+
throw new ParseExit(2, "", `${this.usage()}error BAD_USAGE: ${message}
|
|
3265
|
+
fix: ${fix}
|
|
3266
|
+
`, { code: "BAD_USAGE", message, fix });
|
|
3233
3267
|
}
|
|
3234
3268
|
parseKnown(args, values) {
|
|
3235
3269
|
try {
|
|
@@ -3671,7 +3705,7 @@ var Downloads = class {
|
|
|
3671
3705
|
async fresh(jobId, item2) {
|
|
3672
3706
|
const seq = Number.isInteger(item2.seq) ? item2.seq : 1;
|
|
3673
3707
|
const job = await this.api.get(jobPath(jobId), { frames_after: Math.max(0, seq - 1) });
|
|
3674
|
-
for (const fresh of (job.
|
|
3708
|
+
for (const fresh of (job.frame_links || {}).items || []) if (isObject(fresh) && fresh.frame === item2.frame) return fresh;
|
|
3675
3709
|
return item2;
|
|
3676
3710
|
}
|
|
3677
3711
|
/** Wait for every download asked for; the problems of those that failed. */
|
|
@@ -3704,7 +3738,7 @@ async function fetchStored(api, downloads, jobId) {
|
|
|
3704
3738
|
let cursor = 0;
|
|
3705
3739
|
for (; ; ) {
|
|
3706
3740
|
const job = await api.get(jobPath(jobId), { frames_after: cursor });
|
|
3707
|
-
const page = job.
|
|
3741
|
+
const page = job.frame_links || {};
|
|
3708
3742
|
for (const item2 of page.items || []) if (isObject(item2)) downloads.want(jobId, item2);
|
|
3709
3743
|
cursor = page.next ?? cursor;
|
|
3710
3744
|
if (!page.more) return;
|
|
@@ -3797,13 +3831,13 @@ async function follow(api, job, downloads, progress) {
|
|
|
3797
3831
|
await timing.sleep(POLL_SECONDS);
|
|
3798
3832
|
continue;
|
|
3799
3833
|
}
|
|
3800
|
-
const page = job.
|
|
3834
|
+
const page = job.frame_links || {};
|
|
3801
3835
|
for (const item2 of page.items || []) if (isObject(item2)) downloads.want(jobId, item2);
|
|
3802
3836
|
cursor = page.next ?? cursor;
|
|
3803
3837
|
if (progress) progress.update(job);
|
|
3804
3838
|
if (page.more) continue;
|
|
3805
3839
|
if (!UNFINISHED.includes(job.state)) {
|
|
3806
|
-
delete job.
|
|
3840
|
+
delete job.frame_links;
|
|
3807
3841
|
return job;
|
|
3808
3842
|
}
|
|
3809
3843
|
await timing.sleep(timing.clock() - started < SLOW_AFTER ? POLL_SECONDS : SLOW_POLL_SECONDS);
|
|
@@ -3844,8 +3878,7 @@ async function cancel(args, ui, api) {
|
|
|
3844
3878
|
const name = (job2.blend || {}).name || "";
|
|
3845
3879
|
ui.say(`${job2.id} ${name} ${frames(job2)} ${age(job2.created_at)}`.trimEnd());
|
|
3846
3880
|
}
|
|
3847
|
-
|
|
3848
|
-
return EXIT_USAGE;
|
|
3881
|
+
throw new UsageError(`${running2.length} jobs are running.`, `Name the one to stop, as in renderboy cancel ${running2[0].id}.`);
|
|
3849
3882
|
}
|
|
3850
3883
|
jobId = String(running2[0].id);
|
|
3851
3884
|
}
|
|
@@ -4096,21 +4129,20 @@ function openFile(text2) {
|
|
|
4096
4129
|
stat = fs9.statSync(expanded);
|
|
4097
4130
|
} catch {
|
|
4098
4131
|
}
|
|
4099
|
-
if (stat?.isDirectory()) throw new UsageError(
|
|
4100
|
-
if (!stat?.isFile()) throw new UsageError(`
|
|
4132
|
+
if (stat?.isDirectory()) throw new UsageError(`${text2} is a folder, not a .blend file.`, folderFix(text2, expanded));
|
|
4133
|
+
if (!stat?.isFile()) throw new UsageError(`No such file: ${text2}`, "Pass the path of a saved .blend file: renderboy render FILE.blend.");
|
|
4101
4134
|
return fs9.realpathSync(expanded);
|
|
4102
4135
|
}
|
|
4103
|
-
function
|
|
4136
|
+
function folderFix(text2, dir) {
|
|
4104
4137
|
let blends = [];
|
|
4105
4138
|
try {
|
|
4106
4139
|
blends = fs9.readdirSync(dir).filter((name) => name.toLowerCase().endsWith(".blend")).sort();
|
|
4107
4140
|
} catch {
|
|
4108
4141
|
}
|
|
4109
|
-
|
|
4110
|
-
if (
|
|
4111
|
-
if (blends.length === 1) return `${what}: name the file, like renderboy render ${path9.join(text2, blends[0])}`;
|
|
4142
|
+
if (!blends.length) return "It holds no .blend file: name the .blend file to render, renderboy render FILE.blend.";
|
|
4143
|
+
if (blends.length === 1) return `Name the file: renderboy render ${path9.join(text2, blends[0])}.`;
|
|
4112
4144
|
const shown = blends.slice(0, 3).join(", ") + (blends.length > 3 ? ", \u2026" : "");
|
|
4113
|
-
return
|
|
4145
|
+
return `Name one of the .blend files in it (${shown}).`;
|
|
4114
4146
|
}
|
|
4115
4147
|
function readHeader(file) {
|
|
4116
4148
|
const version = savedBy(file);
|
|
@@ -4305,6 +4337,7 @@ async function send(storage, file, parts, partSize, slow2) {
|
|
|
4305
4337
|
}
|
|
4306
4338
|
|
|
4307
4339
|
// src/render.ts
|
|
4340
|
+
var FARM_OUTPUTS = { waitSeconds: 300, everySeconds: 3 };
|
|
4308
4341
|
var steps = { find, check, pack, make };
|
|
4309
4342
|
function summary(checked, wanted) {
|
|
4310
4343
|
const facts = checked.facts;
|
|
@@ -4531,10 +4564,17 @@ var Render = class {
|
|
|
4531
4564
|
const frames2 = wanted.map((f) => [f, folder.path(f)]);
|
|
4532
4565
|
const made = {};
|
|
4533
4566
|
if (frames2.length < 2) folder.removeOutput("video");
|
|
4567
|
+
const outputs = [["video", VIDEO, "video"], ["contact_sheet", SHEET, "sheet"]];
|
|
4568
|
+
const missing = outputs.some(([kind]) => (kind !== "video" || frames2.length > 1) && folder.outputFor(kind, this.key) === null);
|
|
4569
|
+
const farm = missing ? await this.farmOutputs() : null;
|
|
4534
4570
|
const encoding = new Slow(this.ui, frames2.length > 1 ? "Making the video and the contact sheet\u2026" : "Making the contact sheet\u2026");
|
|
4535
|
-
for (const [kind, name, what] of
|
|
4571
|
+
for (const [kind, name, what] of outputs) {
|
|
4536
4572
|
if (kind === "video" && frames2.length < 2) continue;
|
|
4537
4573
|
made[kind] = folder.outputFor(kind, this.key);
|
|
4574
|
+
if (made[kind] === null && farm !== null && await this.download(farm, kind, path10.join(folder.root, name))) {
|
|
4575
|
+
folder.setOutput(kind, name, this.key);
|
|
4576
|
+
made[kind] = path10.join(folder.root, name);
|
|
4577
|
+
}
|
|
4538
4578
|
if (made[kind] === null) {
|
|
4539
4579
|
try {
|
|
4540
4580
|
await steps.make(this.checked.blender, what, frames2, path10.join(folder.root, name), this.checked.local, () => encoding.tick());
|
|
@@ -4558,6 +4598,48 @@ var Render = class {
|
|
|
4558
4598
|
if (this.ui.json) this.ui.emit(this.document());
|
|
4559
4599
|
return EXIT_OK;
|
|
4560
4600
|
}
|
|
4601
|
+
/**
|
|
4602
|
+
* The job whose video and contact sheet the folder can take: done, every frame of this command
|
|
4603
|
+
* from it, and the farm has made them (`outputs.state` done), with their links. While the farm
|
|
4604
|
+
* is making them it waits, at most FARM_OUTPUTS.waitSeconds. Null otherwise: they are made here.
|
|
4605
|
+
*/
|
|
4606
|
+
async farmOutputs() {
|
|
4607
|
+
const job = this.job;
|
|
4608
|
+
if (job === null || job.state !== "done" || this.wanted.length < 2) return null;
|
|
4609
|
+
const entries = this.folder.note.frames;
|
|
4610
|
+
if (!this.wanted.every((f) => entries[String(f)]?.job === job.id)) return null;
|
|
4611
|
+
const until = timing.clock() + FARM_OUTPUTS.waitSeconds;
|
|
4612
|
+
const waiting2 = new Slow(this.ui, "Waiting for the farm's video and contact sheet\u2026");
|
|
4613
|
+
for (; ; ) {
|
|
4614
|
+
const read2 = await this.api.get(jobPath(job.id));
|
|
4615
|
+
const state = (read2.outputs || {}).state;
|
|
4616
|
+
if (state === "done" && typeof read2.video?.url === "string" && typeof read2.contact_sheet?.url === "string") return read2;
|
|
4617
|
+
if (state !== "making" || timing.clock() >= until) return null;
|
|
4618
|
+
waiting2.tick();
|
|
4619
|
+
await timing.sleep(FARM_OUTPUTS.everySeconds);
|
|
4620
|
+
}
|
|
4621
|
+
}
|
|
4622
|
+
/** Downloads the farm's `kind` (`video`, `contact_sheet`) to `dest`, its size checked; false when it can't (it is then made here). */
|
|
4623
|
+
async download(job, kind, dest) {
|
|
4624
|
+
const fetching = new Slow(this.ui, "Downloading the video and the contact sheet\u2026");
|
|
4625
|
+
for (let round = 0; round < 2; round++) {
|
|
4626
|
+
const file = (round ? (await this.api.get(jobPath(job.id)))[kind] : job[kind]) || {};
|
|
4627
|
+
if (typeof file.url !== "string" || !Number.isInteger(file.size)) return false;
|
|
4628
|
+
try {
|
|
4629
|
+
fetching.tick();
|
|
4630
|
+
await this.storage.download(file.url, dest, file.size);
|
|
4631
|
+
return true;
|
|
4632
|
+
} catch (err2) {
|
|
4633
|
+
if (err2 instanceof Expired) continue;
|
|
4634
|
+
if (err2 instanceof Problem) {
|
|
4635
|
+
fs10.rmSync(`${dest}.part`, { force: true });
|
|
4636
|
+
return false;
|
|
4637
|
+
}
|
|
4638
|
+
throw err2;
|
|
4639
|
+
}
|
|
4640
|
+
}
|
|
4641
|
+
return false;
|
|
4642
|
+
}
|
|
4561
4643
|
framesLine() {
|
|
4562
4644
|
const have = this.wanted.filter(this.has);
|
|
4563
4645
|
if (have.length === this.wanted.length) {
|
|
@@ -4570,7 +4652,9 @@ var Render = class {
|
|
|
4570
4652
|
}
|
|
4571
4653
|
document() {
|
|
4572
4654
|
const doc = { ...this.job ?? {} };
|
|
4573
|
-
delete doc.
|
|
4655
|
+
delete doc.frame_links;
|
|
4656
|
+
delete doc.video;
|
|
4657
|
+
delete doc.contact_sheet;
|
|
4574
4658
|
doc.folder = this.folder.root;
|
|
4575
4659
|
doc.frames_in_folder = this.wanted.filter(this.has).length;
|
|
4576
4660
|
doc.video = this.folder.outputFor("video", this.key);
|
|
@@ -4642,7 +4726,7 @@ description: Renders Blender .blend scenes and animations on cloud GPUs with the
|
|
|
4642
4726
|
|
|
4643
4727
|
## Money
|
|
4644
4728
|
|
|
4645
|
-
- Price: ${PRICE}. Each job is capped by \`--max-spend\` (default ${usd(DEFAULT_MAX_SPEND_USD)}, or the spare credit if less; at least
|
|
4729
|
+
- Price: ${PRICE}. Each job is capped by \`--max-spend\` (default ${usd(DEFAULT_MAX_SPEND_USD)}, or the spare credit if less; at least the job's minimum). Always pass the cap the person agreed to.
|
|
4646
4730
|
- A render that is running prints its progress: read that. Never start a render again to check on one.
|
|
4647
4731
|
- Killed or timed out, \`render\` only detaches and the job keeps rendering: run the exact same command to follow it. Frames already in the output folder are not rendered again, whatever \`--frames\` asks, until the .blend or a file it uses changes: then every frame asked for is rendered, and paid, again.
|
|
4648
4732
|
- A check that fails (exit 3) uploads nothing and costs nothing, and neither does a job that fails before its first frame is stored: do what the \`fix:\` line says, then run the same command again.
|
|
@@ -5108,7 +5192,7 @@ function npmEnv(from = process.env) {
|
|
|
5108
5192
|
env2.npm_config_update_notifier = "false";
|
|
5109
5193
|
return env2;
|
|
5110
5194
|
}
|
|
5111
|
-
var NPM_FLAGS = ["--no-audit", "--no-fund", "--ignore-scripts", "--loglevel=error", "--fetch-retries=1", "--fetch-retry-mintimeout=2000", "--fetch-retry-maxtimeout=10000"];
|
|
5195
|
+
var NPM_FLAGS = ["--prefer-online", "--no-audit", "--no-fund", "--ignore-scripts", "--loglevel=error", "--fetch-retries=1", "--fetch-retry-mintimeout=2000", "--fetch-retry-maxtimeout=10000"];
|
|
5112
5196
|
async function starts(script, version) {
|
|
5113
5197
|
const { code, out } = await runProgram(process.execPath, [script, "--version"], { env: { ...process.env, RENDERBOY_NO_UPDATE: "1" }, timeout: STARTS_TIMEOUT });
|
|
5114
5198
|
return code === 0 && out.trim() === `renderboy ${version}`;
|
|
@@ -5353,6 +5437,10 @@ function makeApi() {
|
|
|
5353
5437
|
}
|
|
5354
5438
|
return new Api(base, key, source);
|
|
5355
5439
|
}
|
|
5440
|
+
function asksJson(argv2) {
|
|
5441
|
+
const options = argv2.includes("--") ? argv2.slice(0, argv2.indexOf("--")) : argv2;
|
|
5442
|
+
return argv2[0] === "render" && options.some((a) => a.length >= 3 && "--json".startsWith(a));
|
|
5443
|
+
}
|
|
5356
5444
|
var commands = { render: cmdRender, cancel: cmdCancel, balance: cmdBalance, login: cmdLogin, logout: cmdLogout, skill: cmdSkill };
|
|
5357
5445
|
async function main(argv2) {
|
|
5358
5446
|
if (argv2[0] !== "skill") keepCurrent();
|
|
@@ -5364,6 +5452,8 @@ async function main(argv2) {
|
|
|
5364
5452
|
if (!(err2 instanceof ParseExit)) throw err2;
|
|
5365
5453
|
if (err2.out) streams.out(err2.out);
|
|
5366
5454
|
if (err2.err) streams.err(err2.err);
|
|
5455
|
+
if (err2.problem && asksJson(argv2)) streams.out(`${toJson({ error: err2.problem })}
|
|
5456
|
+
`);
|
|
5367
5457
|
return err2.code;
|
|
5368
5458
|
}
|
|
5369
5459
|
const command = args.command;
|
|
@@ -5375,17 +5465,14 @@ async function main(argv2) {
|
|
|
5375
5465
|
try {
|
|
5376
5466
|
if (command === "render") {
|
|
5377
5467
|
const maxSpend = args.max_spend ?? null;
|
|
5378
|
-
|
|
5379
|
-
|
|
5468
|
+
if (maxSpend !== null && maxSpend < MIN_CHARGE_PER_GPU_USD) {
|
|
5469
|
+
throw new Problem("SPEND_CAP_TOO_LOW", `--max-spend ${fixed(maxSpend, 2)} is under ${moneyText(MIN_CHARGE_PER_GPU_USD)}, the minimum charge of a job on 1 GPU.`);
|
|
5470
|
+
}
|
|
5380
5471
|
return await commands.render({ file: args.file, frames: args.frames ?? null, gpus: args.gpus ?? null, maxSpend, json: args.json === true }, ui, makeApi);
|
|
5381
5472
|
}
|
|
5382
5473
|
if (command === "cancel") return await commands.cancel({ job: args.job ?? null }, ui, makeApi);
|
|
5383
5474
|
return await commands[command](args, ui, makeApi);
|
|
5384
5475
|
} catch (err2) {
|
|
5385
|
-
if (err2 instanceof UsageError) {
|
|
5386
|
-
ui.tell(`error: ${err2.message}`);
|
|
5387
|
-
return EXIT_USAGE;
|
|
5388
|
-
}
|
|
5389
5476
|
if (err2 instanceof Problem) {
|
|
5390
5477
|
let problem = err2;
|
|
5391
5478
|
if (err2.code === "CLI_TOO_OLD") {
|