Updated README and comments

This commit is contained in:
atmaranto
2024-03-07 04:09:07 -06:00
parent 5fe795c13e
commit 3ad6de7ce4
2 changed files with 13 additions and 6 deletions
+6 -2
View File
@@ -1,6 +1,6 @@
## ComfyUI-to-Python-Extension (SaveAsScript version)
This is a fork of the [ComfyUI-To-Python-Extension](https://github.com/pydn/ComfyUI-to-Python-Extension) by Peyton DeNiro. It provides a more robust command-line interface and the ability to export your current workflow as a script directly from the ComfyUI web interface.
This is a fork maintained by Anthony Maranto of the original [ComfyUI-To-Python-Extension](https://github.com/pydn/ComfyUI-to-Python-Extension) by Peyton DeNiro. It provides a more robust command-line interface and the ability to export your current workflow as a script directly from the ComfyUI web interface.
### Usage (Web)
@@ -8,7 +8,7 @@ Upon installation, there will be a button labeled "Save as Script" on the interf
![A button that exports the current script on the ComfyUI](images/save_as_script.png)
Click that button and enter your preferred name for the downloaded script (no ".py" is appeneded automatically), and your file will be downloaded.
Click that button and enter your preferred name for the downloaded script (extension not added automatically), and your file will be downloaded.
Note that if you use the script this way, you do **not** need to enable developer mode. You *will* if you use the CLI (to get the API JSON).
@@ -33,6 +33,10 @@ options:
Overwrite the output file if it exists
```
### Other Changes
I also fixed what seemed to be a minor bug with exporting certain Crystools nodes, possibly due to their unusual name.
## Original Description
The `ComfyUI-to-Python-Extension` is a powerful tool that translates [ComfyUI](https://github.com/comfyanonymous/ComfyUI) workflows into executable Python code. Designed to bridge the gap between ComfyUI's visual interface and Python's programming environment, this script facilitates the seamless transition from design to code execution. Whether you're a data scientist, a software developer, or an AI enthusiast, this tool streamlines the process of implementing ComfyUI workflows in Python.
+7 -4
View File
@@ -400,12 +400,12 @@ class ComfyUItoPython:
"""
def __init__(self, workflow: str = "", input_file: str = "", output_file: (str | TextIO) = "", queue_size: int = 10, node_class_mappings: Dict = NODE_CLASS_MAPPINGS):
"""Initialize the ComfyUItoPython class with the given parameters.
"""Initialize the ComfyUItoPython class with the given parameters. Exactly one of workflow or input_file must be specified.
Args:
workflow (str): The
workflow (str): The workflow's JSON.
input_file (str): Path to the input JSON file.
output_file (str): Path to the output Python file.
output_file (str | TextIO): Path to the output file or a file-like object.
queue_size (int): The number of times a workflow will be executed by the script. Defaults to 10.
node_class_mappings (Dict): Mappings of node classes. Defaults to NODE_CLASS_MAPPINGS.
"""
@@ -414,6 +414,9 @@ class ComfyUItoPython:
elif not input_file and not workflow:
raise ValueError("Needs input_file or workflow")
if not output_file:
raise ValueError("Needs output_file")
self.workflow = workflow
self.input_file = input_file
self.output_file = output_file
@@ -430,7 +433,7 @@ class ComfyUItoPython:
None
"""
#if self.should_init_custom_nodes:
# Step 1: Import all custom nodes (already done for us)
# Step 1: Import all custom nodes (already done for us in this fork)
#import_custom_nodes()
# Step 2: Read JSON data from the input file