Skip to content

Commit badcdf8

Browse files
author
Peyton
committed
Forgot import and fixed proper tabbing for code generation.
1 parent 77965f8 commit badcdf8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

comfyui_to_python.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,12 @@ def assemble_python_code(import_statements: set, loader_code: List[str], code: L
215215
Returns:
216216
final_code (str): Generated final code as a string
217217
"""
218-
static_imports = ['import random']
218+
static_imports = ['import random', 'import torch']
219219
imports_code = [f"from nodes import {', '.join([class_name for class_name in import_statements])}" ]
220-
main_function_code = f"def main():\n\t" + 'with torch.inference_mode():\n\t' + '\n\t'.join(loader_code) + f'\n\n\tfor q in range({queue_size}):\n\t' + '\n\t'.join(code)
220+
main_function_code = f"def main():\n\t" + 'with torch.inference_mode():\n\t\t' + '\n\t\t'.join(loader_code) + f'\n\n\t\tfor q in range({queue_size}):\n\t\t' + '\n\t\t'.join(code)
221221
final_code = '\n'.join(static_imports + ['import sys\nsys.path.append("../")'] + imports_code + ['', main_function_code, '', 'if __name__ == "__main__":', '\tmain()'])
222222
final_code = black.format_str(final_code, mode=black.Mode())
223223

224-
225224
return final_code
226225

227226

0 commit comments

Comments
 (0)