Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Run workflows saved by older versions: reset unusable optional inputs to defaults

Bowen Xueb88c1589d73f
diff --git a/freevideo_engine/comfy_nodes.py b/freevideo_engine/comfy_nodes.py
index e1665b6..c132629 100644
--- a/freevideo_engine/comfy_nodes.py
+++ b/freevideo_engine/comfy_nodes.py
@@ -4,7 +4,7 @@ from pathlib import Path
from comfy_api.latest import ComfyExtension, InputImpl, io, ui
-from . import comfy_bridge
+from . import comfy_bridge, workflow_repairs
from .comfy_continuation import node_frames, optional_text, part_steps, request_options
from .default_prompt import DEFAULT_PROMPT
@@ -20,9 +20,12 @@ def clean_prompt(json_data):
ComfyUI rejects '' or None for an integer input before validate_inputs runs, so the value is
read here the same way the node reads it (node_frames): anything that is not a count the model
- makes follows Duration. Links and other nodes are left as they are.
+ makes follows Duration. The optional inputs an older workflow holds in a form the node refuses
+ (workflow_repairs) fall back to their defaults and are noted for the diagnostic report. Links and
+ other nodes are left as they are.
"""
prompt = json_data.get('prompt') if isinstance(json_data, dict) else None
+ repaired = []
for node in prompt.values() if isinstance(prompt, dict) else ():
inputs = node.get('inputs') if isinstance(node, dict) and node.get('class_type') == 'FreeVideoGenerate' else None
if isinstance(inputs, dict) and 'frames' in inputs and not isinstance(inputs['frames'], list):
@@ -31,6 +34,15 @@ def clean_prompt(json_data):
logging.info('[FreeVideo] Total frames %r is not a frame count; the length follows Duration.',
str(inputs['frames'])[:40])
inputs['frames'] = frames
+ if isinstance(inputs, dict):
+ repaired += workflow_repairs.repair_inputs(inputs)
+ if repaired:
+ logging.info('[FreeVideo] Optional inputs from an older workflow were reset to their defaults: %s.',
+ ', '.join(sorted(set(repaired))))
+ try:
+ workflow_repairs.record(comfy_bridge.installation_root(), 'request', repaired)
+ except (OSError, ValueError) as error:
+ logging.warning('[FreeVideo] Could not note the reset inputs: %s', error)
return json_data
diff --git a/freevideo_engine/diagnostics.py b/freevideo_engine/diagnostics.py
index 5c73215..41170e4 100644
--- a/freevideo_engine/diagnostics.py
+++ b/freevideo_engine/diagnostics.py
@@ -403,7 +403,7 @@ def collect(root, config, run, output, *, complete=False, extra_files=(), notes=
# What the browser page found (web/health.js), and the page files of the
# source ComfyUI served: a missing or changed file explains a page
# without FreeVideo's styles or workspace.
- for name in ('page-check.json', 'page-checks.jsonl'):
+ for name in ('page-check.json', 'page-checks.jsonl', 'workflow-repairs.jsonl'):
if (root / 'logs' / name).is_file():
add_path('logs/' + name, root / 'logs' / name)
add('source/web-files.json', json.dumps(web_files(root, machine)).encode())
diff --git a/freevideo_engine/workflow_repairs.py b/freevideo_engine/workflow_repairs.py
new file mode 100644
index 0000000..37c2b2f
--- /dev/null
+++ b/freevideo_engine/workflow_repairs.py
@@ -0,0 +1,65 @@
+"""Optional Generate inputs that a workflow from an older version can hold in a form the node refuses.
+
+The inputs below were appended after the first public workflow, so an older save holds an empty or
+missing value in their place and ComfyUI refuses the whole request before the node runs. Each one
+falls back to its default. Prompt, size, duration, seed and step counts are not here: a wrong value
+in those is a real error and keeps its message.
+"""
+import json
+import time
+
+from .long_paths import io_path
+
+# name -> (kind, default, options); kept equal to the node's inputs by tests/test_workflow_repairs.py.
+TOLERATED = {
+ 'force_regenerate': ('bool', False, None),
+ 'preview': ('bool', False, None),
+ 'refine_from': ('text', '', None),
+ 'continue_from': ('text', '', None),
+ 'first_frame_reference': ('bool', False, None),
+ 'voice_reference': ('bool', False, None),
+ 'hide_tail': ('bool', False, None),
+ 'step_cache': ('choice', 'none', ('none', 'easycache-av', 'fbcache')),
+ 'upscale_factor': ('choice', '2', ('2', '1.5', '1.2')),
+}
+KEPT = 50
+
+
+def tolerated_value(name, value):
+ kind, default, options = TOLERATED[name]
+ if kind == 'bool':
+ return value if isinstance(value, bool) else default
+ if kind == 'text':
+ return value if isinstance(value, str) else default
+ if isinstance(value, (int, float)) and not isinstance(value, bool):
+ value = '%g' % value
+ return value if value in options else default
+
+
+def repair_inputs(inputs):
+ """Reset the tolerated inputs that hold an unusable value; returns the names changed.
+
+ A value that is a link (a list) or an input the request does not have is left as it is."""
+ changed = []
+ for name in TOLERATED:
+ if name not in inputs or isinstance(inputs[name], list):
+ continue
+ value = tolerated_value(name, inputs[name])
+ if value != inputs[name] or type(value) is not type(inputs[name]):
+ was_number = isinstance(inputs[name], (int, float)) and not isinstance(inputs[name], bool)
+ if not (was_number and value == '%g' % inputs[name]):
+ changed.append(name)
+ inputs[name] = value
+ return changed
+
+
+def record(engine_root, origin, names):
+ """Keep a short history of what was reset for the diagnostic report (logs/workflow-repairs.jsonl)."""
+ if not names:
+ return
+ logs = io_path(engine_root) / 'logs'
+ logs.mkdir(parents=True, exist_ok=True)
+ history = logs / 'workflow-repairs.jsonl'
+ line = json.dumps(dict(at=time.strftime('%Y-%m-%dT%H:%M:%S%z'), origin=origin, reset=sorted(set(names))))
+ rows = history.read_text(encoding='utf-8').splitlines()[-(KEPT - 1):] if history.is_file() else []
+ history.write_text('\n'.join([*rows, line]) + '\n', encoding='utf-8')
diff --git a/web/optional_inputs.js b/web/optional_inputs.js
index b145858..7f3404a 100644
--- a/web/optional_inputs.js
+++ b/web/optional_inputs.js
@@ -2,12 +2,14 @@
// shape. A workflow restored from an older version, or a widget list that moved,
// can leave an empty or missing value in them, and Comfy then rejects the whole
// request. Keep each of them to a value the server accepts.
-const DEFAULTS = {refine_from: '', continue_from: '', frames: 0, first_frame_reference: false, step_cache: 'none', upscale_factor: '2'};
+const DEFAULTS = {refine_from: '', continue_from: '', frames: 0, first_frame_reference: false, force_regenerate: false, preview: false, voice_reference: false, hide_tail: false, step_cache: 'none', upscale_factor: '2'};
// A workflow saved before Step cache existed holds '' where it now sits.
const STEP_CACHE_OPTIONS = ['none', 'easycache-av', 'fbcache'];
// Likewise for Upscale factor, appended after Step cache.
const UPSCALE_OPTIONS = ['2', '1.5', '1.2'];
+const BOOLEANS = new Set(['first_frame_reference', 'force_regenerate', 'preview', 'voice_reference', 'hide_tail']);
+
// The words a script, an older workflow or String(null) leaves behind for "not given".
const EMPTY_WORDS = new Set(['none', 'null', 'undefined', 'nan']);
@@ -27,7 +29,7 @@ export function frameCount(value) {
export function optionalInputValue(name, value) {
if (name === 'frames') return frameCount(value);
if (name === 'refine_from' || name === 'continue_from') return optionalText(value);
- if (name === 'first_frame_reference') return value === true;
+ if (BOOLEANS.has(name)) return value === true;
if (name === 'step_cache') return STEP_CACHE_OPTIONS.includes(value) ? value : 'none';
if (name === 'upscale_factor') return UPSCALE_OPTIONS.includes(value) ? value : '2';
return value;