From fac377cf03d088099f5271fc12220182b39188af Mon Sep 17 00:00:00 2001 From: Ryu Xin Date: Sat, 24 Feb 2024 14:37:08 +0800 Subject: [PATCH 1/2] add queue_summary and output request handler --- nodes.py | 2 ++ server.py | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/nodes.py b/nodes.py index a577c2126..c9799575f 100644 --- a/nodes.py +++ b/nodes.py @@ -1911,6 +1911,8 @@ def load_custom_nodes(): node_paths = folder_paths.get_folder_paths("custom_nodes") node_import_times = [] for custom_node_path in node_paths: + if not os.path.exists(custom_node_path): + continue possible_modules = os.listdir(os.path.realpath(custom_node_path)) if "__pycache__" in possible_modules: possible_modules.remove("__pycache__") diff --git a/server.py b/server.py index dca06f6fc..84494e875 100644 --- a/server.py +++ b/server.py @@ -443,6 +443,23 @@ class PromptServer(): prompt_id = request.match_info.get("prompt_id", None) return web.json_response(self.prompt_queue.get_history(prompt_id=prompt_id)) + @routes.get("/output/{prompt_id}") + async def get_output_id(request): + str = request.match_info.get("prompt_id", None) + output = {} + if str is None: + return web.json_response(output) + prompt_ids = str.split(",") + for prompt_id in prompt_ids: + the_result = self.prompt_queue.get_history(prompt_id=prompt_id) + if len(the_result) == 0: + return web.json_response(output) + + result_info = {'outputs': the_result[prompt_id]['outputs']} + output[prompt_id] = result_info + + return web.json_response(output) + @routes.get("/queue") async def get_queue(request): queue_info = {} @@ -451,6 +468,29 @@ class PromptServer(): queue_info['queue_pending'] = current_queue[1] return web.json_response(queue_info) + @routes.get("/queue_summary") + async def get_queue_summary(request): + queue_info = {} + current_queue = self.prompt_queue.get_current_queue() + + running_queue = current_queue[0] + running_ids = list() + for queue in running_queue: + prompt_id = queue[1] + running_ids.append(prompt_id) + running_info = {'prompt_id': prompt_id, 'current_node_id': self.last_node_id} + queue_info['running_status'] = running_info + + pending_queue = current_queue[1] + pending_ids = list() + for queue in pending_queue: + pending_ids.append(queue[1]) + + queue_info['queue_running'] = running_ids + queue_info['queue_pending'] = pending_ids + return web.json_response(queue_info) + + @routes.post("/prompt") async def post_prompt(request): print("got prompt") From 03b8cea1dfc915c691d85776080fe161204b58cc Mon Sep 17 00:00:00 2001 From: Ryu Xin Date: Sat, 24 Feb 2024 14:52:27 +0800 Subject: [PATCH 2/2] add queue_summary and output request handler --- execution.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/execution.py b/execution.py index 3e9d53b0e..9b8f26af4 100644 --- a/execution.py +++ b/execution.py @@ -140,9 +140,9 @@ def recursive_execute(server, prompt, outputs, current_item, extra_data, execute input_data_all = None try: input_data_all = get_input_data(inputs, class_def, unique_id, outputs, prompt, extra_data) + server.last_node_id = unique_id if server.client_id is not None: - server.last_node_id = unique_id - server.send_sync("executing", { "node": unique_id, "prompt_id": prompt_id }, server.client_id) + server.send_sync("executing", {"node": unique_id, "prompt_id": prompt_id}, server.client_id) obj = object_storage.get((unique_id, class_type), None) if obj is None: