-
-
Notifications
You must be signed in to change notification settings - Fork 38
Support for generating Python scripts with keyword arguments #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: longredzhong <29575929+longredzhong@users.noreply.github.com>
Co-authored-by: longredzhong <29575929+longredzhong@users.noreply.github.com>
Co-authored-by: longredzhong <29575929+longredzhong@users.noreply.github.com>
… test coverage Co-authored-by: longredzhong <29575929+longredzhong@users.noreply.github.com>
…support Add keyword argument support to transpiler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for generating Python scripts with keyword arguments instead of positional arguments in the WorkflowToScriptTranspiler class. This enhancement allows users to choose between explicit, readable function calls with named parameters and the previous positional style.
- Added
use_keyword_argsparameter throughout the transpiler infrastructure (constructor, factory methods, and CLI) - Implemented
_format_args_as_keywordmethod to format node arguments as keyword arguments - Added comprehensive parameterized tests for verifying keyword argument generation
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/comfy_script/transpile/__init__.py |
Added use_keyword_args parameter to WorkflowToScriptTranspiler class and factory methods; implemented _format_args_as_keyword method; updated _node_to_assign_st to conditionally use keyword argument formatting |
src/comfy_script/transpile/__main__.py |
Added --use-keyword-args CLI flag and passed it through to the transpiler |
tests/transpile/test_transpiler.py |
Added new parameterized test function test_workflow_with_keyword_args with test cases for various workflow types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks for your PR. I've changed the CLI usage to model, clip, vae = CheckpointLoaderSimple('v1-5-pruned-emaonly.ckpt')
conditioning = CLIPTextEncode('beautiful scenery nature glass bottle landscape, , purple galaxy bottle,', clip)
conditioning2 = CLIPTextEncode('text, watermark', clip)
latent = EmptyLatentImage(width=512, height=512, batch_size=1)
latent = KSampler(model=model, seed=156680208700286, steps=20, cfg=8, sampler_name='euler', scheduler='normal', positive=conditioning, negative=conditioning2, latent_image=latent, denoise=1)
image = VAEDecode(latent, vae)
SaveImage(image, 'ComfyUI') |
|
Pre-released in https://github.com/Chaoses-Ib/ComfyScript/releases/tag/v0.7.0a1. |
This pull request adds support for generatingThis pull request adds support for generating Python scripts with keyword arguments instead of positional arguments in the
WorkflowToScriptTranspilerclass and its CLI. This allows users to choose between more explicit, readable function calls and the previous positional style. The change is implemented throughout the transpiler, CLI, and tests.Support for keyword arguments in script generation:
use_keyword_argsparameter to theWorkflowToScriptTranspilerclass and its factory methods (from_image,from_file) to control whether generated scripts use keyword arguments or positional arguments. [1] [2] [3]_format_args_as_keywordmethod to format node arguments as keyword arguments, and updated_node_to_assign_stto use this formatting whenuse_keyword_argsis enabled. [1] [2]CLI and test enhancements:
--use-keyword-argsflag to the CLI, allowing users to generate scripts with keyword arguments via the command line.use_keyword_args=Truematch the expected output for various workflows. Python scripts with keyword arguments instead of positional arguments in theWorkflowToScriptTranspilerclass and its CLI. This allows users to choose between more explicit, readable function calls and the previous positional style. The change is implemented throughout the transpiler, CLI, and tests.Support for keyword arguments in script generation:
use_keyword_argsparameter to theWorkflowToScriptTranspilerclass and its factory methods (from_image,from_file) to control whether generated scripts use keyword arguments or positional arguments. [1] [2] [3]_format_args_as_keywordmethod to format node arguments as keyword arguments, and updated_node_to_assign_stto use this formatting whenuse_keyword_argsis enabled. [1] [2]CLI and test enhancements:
--use-keyword-argsflag to the CLI, allowing users to generate scripts with keyword arguments via the command line.use_keyword_args=Truematch the expected output for various workflows.Example