From 02aa0bbc90fea2eedfbe699ab7f08f35471454be Mon Sep 17 00:00:00 2001 From: tzwm Date: Sat, 20 Jan 2024 16:20:32 +0800 Subject: [PATCH] rename remote_callback to upload_to_remote node --- __init__.py | 6 +++--- nodes/{remote_callback.py => upload_to_remote.py} | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) rename nodes/{remote_callback.py => upload_to_remote.py} (84%) diff --git a/__init__.py b/__init__.py index 9a24363..b53f8e6 100644 --- a/__init__.py +++ b/__init__.py @@ -5,7 +5,7 @@ import server from .utils import collections_path, browser_path, sources_path, download_logs_path, outputs_path from .routes import sources, collections, config, files, downloads -from .nodes import select_inputs, load_image_by_url, xyz_plot, remote_callback +from .nodes import select_inputs, load_image_by_url, xyz_plot, upload_to_remote browser_app = web.Application() browser_app.add_routes([ @@ -44,11 +44,11 @@ NODE_CLASS_MAPPINGS = { "LoadImageByUrl //Browser": load_image_by_url.LoadImageByUrl, "SelectInputs //Browser": select_inputs.SelectInputs, "XyzPlot //Browser": xyz_plot.XyzPlot, - "RemoteCallback //Browser": remote_callback.RemoteCallback, + "UploadToRemote //Browser": upload_to_remote.UploadToRemote, } NODE_DISPLAY_NAME_MAPPINGS = { "LoadImageByUrl //Browser": "Load Image By URL", "SelectInputs //Browser": "Select Node Inputs", "XyzPlot //Browser": "XYZ Plot", - "RemoteCallback //Browser": "Remote Callback", + "UploadToRemote //Browser": "Upload To Remote", } diff --git a/nodes/remote_callback.py b/nodes/upload_to_remote.py similarity index 84% rename from nodes/remote_callback.py rename to nodes/upload_to_remote.py index 4b7ce26..91e4b4b 100644 --- a/nodes/remote_callback.py +++ b/nodes/upload_to_remote.py @@ -8,7 +8,7 @@ import numpy as np import io import base64 -class RemoteCallback: +class UploadToRemote: CATEGORY = "Browser" RETURN_TYPES = () @@ -24,7 +24,7 @@ class RemoteCallback: return { "required": { "images": ["IMAGE", {}], - "callback_url": ["STRING", {}], + "remote_url": ["STRING", {}], "extension": (['jpeg', 'webp', 'png', 'jpg', 'gif'], ), "quality": ("INT", {"default": 85, "min": 1, "max": 100, "step": 1}), "embed_workflow": (["false", "true"],), @@ -39,7 +39,7 @@ class RemoteCallback: } - def run(self, images, callback_url, extension='jpeg', quality=85, embed_workflow='false', track_id=None, unique_id=None, prompt=None): + def run(self, images, remote_url, extension='jpeg', quality=85, embed_workflow='false', track_id=None, unique_id=None, prompt=None): def process_images(images, extension='jpeg', quality=85, embed_workflow='false', prompt=None): results = list() for image in images: @@ -72,7 +72,7 @@ class RemoteCallback: return results - async def callback(images, callback_url, extension='jpeg', quality=85, embed_workflow='false', track_id=None, unique_id=None, prompt=None): + async def callback(images, remote_url, extension='jpeg', quality=85, embed_workflow='false', track_id=None, unique_id=None, prompt=None): data = { "images": process_images(images, extension, quality, embed_workflow, prompt) } @@ -81,13 +81,13 @@ class RemoteCallback: if unique_id: data['unique_id'] = unique_id data = json.dumps(data).encode('utf-8') - res = requests.post(callback_url, data=data) + res = requests.post(remote_url, data=data) # TODO: check the response threading.Thread( target=asyncio.run, - args=(callback(images, callback_url, extension, quality, embed_workflow, track_id, unique_id, prompt),), + args=(callback(images, remote_url, extension, quality, embed_workflow, track_id, unique_id, prompt),), ).start() return ()