@danhachuel/thunderbolt 0.5.72 → 0.5.74
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/hermes_ui/pipeline_worker.py +18 -1
- package/package.json +1 -1
- package/scripts/cli.mjs +29 -5
|
@@ -1243,6 +1243,22 @@ def _valid_artifact_path(value: Any) -> Path | None:
|
|
|
1243
1243
|
return None
|
|
1244
1244
|
|
|
1245
1245
|
|
|
1246
|
+
def _existing_thumbnail_path(task: dict[str, Any], artifacts: dict[str, Any], variant: dict[str, Any]) -> Path | None:
|
|
1247
|
+
"""Find a thumbnail made previously by Pipeline Vídeos or the UI."""
|
|
1248
|
+
candidates: list[Any] = [
|
|
1249
|
+
artifacts.get("thumbnail"),
|
|
1250
|
+
task.get("thumbnail_path"),
|
|
1251
|
+
variant.get("image_path"),
|
|
1252
|
+
]
|
|
1253
|
+
variants = task.get("thumbnail_variants") if isinstance(task.get("thumbnail_variants"), list) else []
|
|
1254
|
+
candidates.extend(item.get("image_path") for item in variants if isinstance(item, dict))
|
|
1255
|
+
for value in candidates:
|
|
1256
|
+
path = _valid_artifact_path(value)
|
|
1257
|
+
if path is not None:
|
|
1258
|
+
return path
|
|
1259
|
+
return None
|
|
1260
|
+
|
|
1261
|
+
|
|
1246
1262
|
def _read_json_artifact(value: Any) -> dict[str, Any] | None:
|
|
1247
1263
|
path = _valid_artifact_path(value)
|
|
1248
1264
|
if path is None:
|
|
@@ -1482,7 +1498,8 @@ def _run_task(task: dict[str, Any]) -> dict[str, Any]:
|
|
|
1482
1498
|
|
|
1483
1499
|
_update(task_id, stage="thumbnail", state="doing", progress=max(86, int(task.get("progress") or 0)), error=None)
|
|
1484
1500
|
current_artifacts = dict((_task_by_id(task_id) or {}).get("artifacts") or artifacts)
|
|
1485
|
-
|
|
1501
|
+
current_task = _task_by_id(task_id) or task
|
|
1502
|
+
existing_thumbnail = _existing_thumbnail_path(current_task, current_artifacts, variant)
|
|
1486
1503
|
if existing_thumbnail is not None:
|
|
1487
1504
|
thumbnail_path = existing_thumbnail
|
|
1488
1505
|
else:
|
package/package.json
CHANGED
package/scripts/cli.mjs
CHANGED
|
@@ -276,14 +276,37 @@ proxy.on("error", (error) => {
|
|
|
276
276
|
proxy.listen(publicPort, "127.0.0.1", () => {
|
|
277
277
|
console.log(`Thunderbolt: interface disponível em http://localhost:${publicPort}/`);
|
|
278
278
|
});
|
|
279
|
-
//
|
|
280
|
-
//
|
|
281
|
-
//
|
|
282
|
-
|
|
279
|
+
// A worker de automação é necessária para canais com automação activa. É
|
|
280
|
+
// iniciada no máximo uma vez por launcher e reiniciada com backoff se terminar
|
|
281
|
+
// inesperadamente; não é criada quando não há trabalho agendado.
|
|
282
|
+
let worker = null;
|
|
283
283
|
const pipelineWorker = null;
|
|
284
284
|
const restartExitCode = 75;
|
|
285
285
|
let shuttingDown = false;
|
|
286
286
|
let child;
|
|
287
|
+
let workerRestartTimer = null;
|
|
288
|
+
|
|
289
|
+
function startAutomationWorker() {
|
|
290
|
+
if (shuttingDown || worker || !hasScheduledAutomation()) return;
|
|
291
|
+
worker = spawn(python, ["-m", "hermes_ui.automation_worker"], {
|
|
292
|
+
cwd: root,
|
|
293
|
+
stdio: "inherit",
|
|
294
|
+
env: runtimeEnv,
|
|
295
|
+
windowsHide: false,
|
|
296
|
+
});
|
|
297
|
+
worker.on("error", (error) => console.error(`Thunderbolt worker: ${error.message}`));
|
|
298
|
+
worker.on("exit", (code, signal) => {
|
|
299
|
+
worker = null;
|
|
300
|
+
if (shuttingDown) return;
|
|
301
|
+
console.error(`Thunderbolt worker: terminou (código ${code ?? "-"}, sinal ${signal ?? "-"}).`);
|
|
302
|
+
if (hasScheduledAutomation()) {
|
|
303
|
+
workerRestartTimer = setTimeout(() => {
|
|
304
|
+
workerRestartTimer = null;
|
|
305
|
+
startAutomationWorker();
|
|
306
|
+
}, 5000);
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
287
310
|
|
|
288
311
|
function startStreamlit() {
|
|
289
312
|
child = spawn(python, [streamlitBootstrap, "run", main, "--server.port", String(backendPort), "--server.address", "127.0.0.1"], {
|
|
@@ -323,10 +346,11 @@ startStreamlit();
|
|
|
323
346
|
const stopWorker = () => {
|
|
324
347
|
shuttingDown = true;
|
|
325
348
|
proxy.close();
|
|
349
|
+
if (workerRestartTimer) clearTimeout(workerRestartTimer);
|
|
326
350
|
if (worker && !worker.killed) worker.kill();
|
|
327
351
|
if (pipelineWorker && !pipelineWorker.killed) pipelineWorker.kill();
|
|
328
352
|
};
|
|
329
353
|
process.on("SIGINT", stopWorker);
|
|
330
354
|
process.on("SIGTERM", stopWorker);
|
|
331
|
-
worker?.on("error", (error) => console.error(`Thunderbolt worker: ${error.message}`));
|
|
332
355
|
pipelineWorker?.on("error", (error) => console.error(`Thunderbolt pipeline worker: ${error.message}`));
|
|
356
|
+
startAutomationWorker();
|