diff --git a/README.md b/README.md index 1b8c09c..b80470b 100644 --- a/README.md +++ b/README.md @@ -87,14 +87,12 @@ Options: ```bash uv run python comfyui_to_python.py \ --input_file workflow_api.json \ - --frontend_workflow_file workflow.json \ --output_file workflow_api.py \ --queue_size 10 ``` Flags: - `--input_file`: input workflow JSON, default `workflow_api.json` -- `--frontend_workflow_file`: optional full frontend workflow JSON for reimportable PNG metadata - `--output_file`: output Python file, default `workflow_api.py` - `--queue_size`: default execution count in the generated script, default `10` @@ -112,9 +110,7 @@ export COMFYUI_PATH=/path/to/ComfyUI The generated script is a workflow export. It does not automatically turn workflow inputs into command-line arguments. -If you want generated images to drag-drop back into ComfyUI from the CLI flow, provide both: -- the API workflow JSON via `--input_file` -- the full frontend workflow JSON via `--frontend_workflow_file` +Scripts exported directly from `File -> Save As Script` in the ComfyUI UI already include the frontend workflow metadata needed for drag-and-drop reimport. Images saved by those scripts can be dropped back into ComfyUI and reopen with the original workflow metadata. ## Troubleshooting diff --git a/comfyui_to_python.py b/comfyui_to_python.py index d53b7ef..b736b95 100644 --- a/comfyui_to_python.py +++ b/comfyui_to_python.py @@ -685,7 +685,6 @@ def run( input_file: str = DEFAULT_INPUT_FILE, output_file: str = DEFAULT_OUTPUT_FILE, queue_size: int = DEFAULT_QUEUE_SIZE, - frontend_workflow_file: str = "", ) -> None: """Generate Python code from a ComfyUI workflow_api.json file. @@ -695,19 +694,12 @@ def run( Defaults to "workflow_api.py". queue_size (int): The number of times a workflow will be executed by the script. Defaults to 1. - frontend_workflow_file (str): Optional path to a full frontend workflow JSON file. - When provided, generated images can preserve reimportable ComfyUI workflow metadata. Returns: None """ ComfyUItoPython( input_file=input_file, - frontend_workflow=( - FileHandler.read_json_file(frontend_workflow_file) - if frontend_workflow_file - else None - ), output_file=output_file, queue_size=queue_size, needs_init_custom_nodes=True, @@ -740,12 +732,6 @@ def main() -> None: help="number of times the workflow will be executed by default", default=DEFAULT_QUEUE_SIZE, ) - parser.add_argument( - "--frontend_workflow_file", - type=str, - help="optional path to a full frontend workflow JSON file for reimportable PNG metadata", - default="", - ) pargs = parser.parse_args() run(**vars(pargs)) print("Done.") diff --git a/tests/test_upscale_model_loader_export.py b/tests/test_upscale_model_loader_export.py index 27e3e22..e6f4035 100644 --- a/tests/test_upscale_model_loader_export.py +++ b/tests/test_upscale_model_loader_export.py @@ -227,7 +227,7 @@ class UpscaleModelLoaderExportTest(unittest.TestCase): self.assertIn("left=get_value_at_index(loadimage_1_23, 0)", generated) self.assertIn("right=get_value_at_index(loadimage_12_3, 0)", generated) - def test_run_accepts_frontend_workflow_file_for_cli_metadata(self): + def test_run_cli_export_leaves_png_workflow_metadata_absent(self): workflow = { "1": { "class_type": "LoadImage", @@ -236,39 +236,13 @@ class UpscaleModelLoaderExportTest(unittest.TestCase): }, } } - frontend_workflow = { - "version": 0.4, - "last_node_id": 1, - "last_link_id": 0, - "nodes": [ - { - "id": 1, - "type": "LoadImage", - "pos": [0, 0], - "size": [210, 60], - "flags": {}, - "order": 0, - "mode": 0, - "inputs": [], - "outputs": [], - "properties": {}, - "widgets_values": ["example.png"], - } - ], - "links": [], - "groups": [], - "config": {}, - "extra": {}, - } with tempfile.TemporaryDirectory() as tmpdir: tmpdir_path = Path(tmpdir) input_file = tmpdir_path / "workflow_api.json" - frontend_file = tmpdir_path / "workflow.json" output_file = tmpdir_path / "workflow_api.py" input_file.write_text(json.dumps(workflow), encoding="utf-8") - frontend_file.write_text(json.dumps(frontend_workflow), encoding="utf-8") with patch( "comfyui_to_python.get_node_class_mappings", @@ -276,15 +250,14 @@ class UpscaleModelLoaderExportTest(unittest.TestCase): ), patch("comfyui_to_python.import_custom_nodes"): run( input_file=str(input_file), - frontend_workflow_file=str(frontend_file), output_file=str(output_file), queue_size=1, ) generated = output_file.read_text(encoding="utf-8") - self.assertIn('"version": 0.4', generated) - self.assertIn('"type": "LoadImage"', generated) + self.assertIn("extra_pnginfo = None", generated) + self.assertNotIn('"workflow": json.loads(', generated) if __name__ == "__main__":