Fix generated workflow torch import order

Move generated torch imports until after add_extra_model_paths runs so exported scripts do not trigger ComfyUI's early-torch warning during startup. Update export assertions and checked-in runtime generated fixtures to match the new main() ordering.
This commit is contained in:
Peyton DeNiro
2026-03-29 15:15:52 -05:00
parent 441dcfebdf
commit 42d0526661
4 changed files with 36 additions and 20 deletions
+2 -2
View File
@@ -76,8 +76,6 @@ class WorkflowRenderer:
"# Workflow execution",
"def main():",
" bootstrap_comfyui_runtime()",
" import torch",
"",
" add_extra_model_paths()",
]
if custom_nodes_call:
@@ -87,6 +85,8 @@ class WorkflowRenderer:
execution_section.extend(f" {line}" for line in imports_code)
execution_section.extend(
[
"",
" import torch",
"",
" with torch.inference_mode():",
]