From fe39d22eb9ccf602a9beeb9930458a308c78b001 Mon Sep 17 00:00:00 2001 From: Acly Date: Sat, 7 Dec 2024 19:49:00 +0100 Subject: [PATCH] Return a more specific error when inspect model folder doesn't exist --- README.md | 6 +++--- api.py | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a4fb40e..de0e4cb 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ Provides nodes and API geared towards using ComfyUI as a backend for external to ## Sending and receiving images ComfyUI exchanges images via the filesystem. This requires a -multi-step process (upload images, prompt, download images), is rather -inefficient, and invites a whole class of potential issues. It's also unclear -at which point those images will get cleaned up if ComfyUI is used +multi-step process (upload images, prompt, download images), which +invites a whole class of potential issues you might not want to deal with. +It's also unclear at which point those images will get cleaned up if ComfyUI is used via external tools. ### Load Image (Base64) diff --git a/api.py b/api.py index cd6e8c0..d3b8c85 100644 --- a/api.py +++ b/api.py @@ -139,10 +139,14 @@ def inspect_diffusion_model(filename: str, model_type: str, is_checkpoint: bool) def inspect_models(model_type: str): try: + try: + files = folder_paths.get_filename_list(model_type) + except KeyError: + return {"error": f"Model folder not found: {model_type}"} is_checkpoint = model_type == "checkpoints" info = { filename: inspect_diffusion_model(filename, model_type, is_checkpoint) - for filename in folder_paths.get_filename_list(model_type) + for filename in files } return web.json_response(info) except Exception as e: