Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1031487e1 |
@@ -8,6 +8,16 @@ class ComfyUIDeployExternalBoolean:
|
||||
{"multiline": False, "default": "input_bool"},
|
||||
),
|
||||
"default_value": ("BOOLEAN", {"default": False})
|
||||
},
|
||||
"optional": {
|
||||
"display_name": (
|
||||
"STRING",
|
||||
{"multiline": False, "default": "Name of the node (optional)"},
|
||||
),
|
||||
"description": (
|
||||
"STRING",
|
||||
{"multiline": True, "default": "Description of the node (optional)"},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +26,7 @@ class ComfyUIDeployExternalBoolean:
|
||||
|
||||
FUNCTION = "run"
|
||||
|
||||
def run(self, input_id, default_value=None):
|
||||
def run(self, input_id, default_value=None, display_name=None, description=None):
|
||||
print(f"Node '{input_id}' processing with switch set to {default_value}")
|
||||
return [default_value]
|
||||
|
||||
|
||||
@@ -23,6 +23,14 @@ class ComfyUIDeployExternalCheckpoint:
|
||||
},
|
||||
"optional": {
|
||||
"default_value": (folder_paths.get_filename_list("checkpoints"), ),
|
||||
"display_name": (
|
||||
"STRING",
|
||||
{"multiline": False, "default": "Name of the node (optional)"},
|
||||
),
|
||||
"description": (
|
||||
"STRING",
|
||||
{"multiline": True, "default": "Description of the node (optional)"},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +41,7 @@ class ComfyUIDeployExternalCheckpoint:
|
||||
|
||||
CATEGORY = "deploy"
|
||||
|
||||
def run(self, input_id, default_value=None):
|
||||
def run(self, input_id, default_value=None, display_name=None, description=None):
|
||||
import requests
|
||||
import os
|
||||
import uuid
|
||||
|
||||
@@ -15,6 +15,14 @@ class ComfyUIDeployExternalImage:
|
||||
},
|
||||
"optional": {
|
||||
"default_value": ("IMAGE",),
|
||||
"display_name": (
|
||||
"STRING",
|
||||
{"multiline": False, "default": "Name of the node (optional)"},
|
||||
),
|
||||
"description": (
|
||||
"STRING",
|
||||
{"multiline": True, "default": "Description of the node (optional)"},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +33,7 @@ class ComfyUIDeployExternalImage:
|
||||
|
||||
CATEGORY = "image"
|
||||
|
||||
def run(self, input_id, default_value=None):
|
||||
def run(self, input_id, default_value=None, display_name=None, description=None):
|
||||
image = default_value
|
||||
try:
|
||||
if input_id.startswith('http'):
|
||||
|
||||
@@ -15,6 +15,14 @@ class ComfyUIDeployExternalImageAlpha:
|
||||
},
|
||||
"optional": {
|
||||
"default_value": ("IMAGE",),
|
||||
"display_name": (
|
||||
"STRING",
|
||||
{"multiline": False, "default": "Name of the node (optional)"},
|
||||
),
|
||||
"description": (
|
||||
"STRING",
|
||||
{"multiline": True, "default": "Description of the node (optional)"},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +33,7 @@ class ComfyUIDeployExternalImageAlpha:
|
||||
|
||||
CATEGORY = "image"
|
||||
|
||||
def run(self, input_id, default_value=None):
|
||||
def run(self, input_id, default_value=None, display_name=None, description=None):
|
||||
image = default_value
|
||||
try:
|
||||
if input_id.startswith('http'):
|
||||
|
||||
@@ -21,6 +21,14 @@ class ComfyUIDeployExternalImageBatch:
|
||||
},
|
||||
"optional": {
|
||||
"default_value": ("IMAGE",),
|
||||
"display_name": (
|
||||
"STRING",
|
||||
{"multiline": False, "default": "Name of the node (optional)"},
|
||||
),
|
||||
"description": (
|
||||
"STRING",
|
||||
{"multiline": True, "default": "Description of the node (optional)"},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +39,7 @@ class ComfyUIDeployExternalImageBatch:
|
||||
|
||||
CATEGORY = "image"
|
||||
|
||||
def run(self, input_id, images=None, default_value=None):
|
||||
def run(self, input_id, images=None, default_value=None, display_name=None, description=None):
|
||||
processed_images = []
|
||||
try:
|
||||
images_list = json.loads(images) # Assuming images is a JSON array string
|
||||
|
||||
@@ -29,6 +29,14 @@ class ComfyUIDeployExternalLora:
|
||||
"STRING",
|
||||
{"multiline": False, "default": ""},
|
||||
),
|
||||
"display_name": (
|
||||
"STRING",
|
||||
{"multiline": False, "default": "Name of the node (optional)"},
|
||||
),
|
||||
"description": (
|
||||
"STRING",
|
||||
{"multiline": True, "default": "Description of the node (optional)"},
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -39,7 +47,7 @@ class ComfyUIDeployExternalLora:
|
||||
|
||||
CATEGORY = "deploy"
|
||||
|
||||
def run(self, input_id, default_lora_name=None, lora_save_name=None):
|
||||
def run(self, input_id, default_lora_name=None, lora_save_name=None, display_name=None, description=None):
|
||||
import requests
|
||||
import os
|
||||
import uuid
|
||||
|
||||
@@ -18,6 +18,14 @@ class ComfyUIDeployExternalNumber:
|
||||
"FLOAT",
|
||||
{"multiline": True, "display": "number", "default": 0, "min": -2147483647, "max": 2147483647, "step": 0.01},
|
||||
),
|
||||
"display_name": (
|
||||
"STRING",
|
||||
{"multiline": False, "default": "Name of the node (optional)"},
|
||||
),
|
||||
"description": (
|
||||
"STRING",
|
||||
{"multiline": True, "default": "Description of the node (optional)"},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +36,7 @@ class ComfyUIDeployExternalNumber:
|
||||
|
||||
CATEGORY = "number"
|
||||
|
||||
def run(self, input_id, default_value=None):
|
||||
def run(self, input_id, default_value=None, display_name=None, description=None):
|
||||
try:
|
||||
float_value = float(input_id)
|
||||
print("my number", float_value)
|
||||
|
||||
@@ -18,6 +18,14 @@ class ComfyUIDeployExternalNumberInt:
|
||||
"INT",
|
||||
{"multiline": True, "display": "number", "min": -2147483647, "max": 2147483647, "default": 0},
|
||||
),
|
||||
"display_name": (
|
||||
"STRING",
|
||||
{"multiline": False, "default": "Name of the node (optional)"},
|
||||
),
|
||||
"description": (
|
||||
"STRING",
|
||||
{"multiline": True, "default": "Description of the node (optional)"},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +36,7 @@ class ComfyUIDeployExternalNumberInt:
|
||||
|
||||
CATEGORY = "number"
|
||||
|
||||
def run(self, input_id, default_value=None):
|
||||
def run(self, input_id, default_value=None, display_name=None, description=None):
|
||||
if not input_id or (isinstance(input_id, str) and not input_id.strip().isdigit()):
|
||||
return [default_value]
|
||||
return [int(input_id)]
|
||||
|
||||
@@ -21,6 +21,14 @@ class ComfyUIDeployExternalNumberSlider:
|
||||
"FLOAT",
|
||||
{"multiline": True, "display": "number", "min": -2147483647, "max": 2147483647, "default": 1, "step": 0.01},
|
||||
),
|
||||
"display_name": (
|
||||
"STRING",
|
||||
{"multiline": False, "default": "Name of the node (optional)"},
|
||||
),
|
||||
"description": (
|
||||
"STRING",
|
||||
{"multiline": True, "default": "Description of the node (optional)"},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +39,7 @@ class ComfyUIDeployExternalNumberSlider:
|
||||
|
||||
CATEGORY = "number"
|
||||
|
||||
def run(self, input_id, default_value=None, min_value=0, max_value=1):
|
||||
def run(self, input_id, default_value=None, min_value=0, max_value=1, display_name=None, description=None):
|
||||
try:
|
||||
float_value = float(input_id)
|
||||
if min_value <= float_value <= max_value:
|
||||
|
||||
@@ -18,6 +18,14 @@ class ComfyUIDeployExternalText:
|
||||
"STRING",
|
||||
{"multiline": True, "default": ""},
|
||||
),
|
||||
"display_name": (
|
||||
"STRING",
|
||||
{"multiline": False, "default": "Name of the node (optional)"},
|
||||
),
|
||||
"description": (
|
||||
"STRING",
|
||||
{"multiline": True, "default": "Description of the node (optional)"},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +36,7 @@ class ComfyUIDeployExternalText:
|
||||
|
||||
CATEGORY = "text"
|
||||
|
||||
def run(self, input_id, default_value=None):
|
||||
def run(self, input_id, default_value=None, display_name=None, description=None):
|
||||
return [default_value]
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,16 @@ class ComfyUIDeployExternalTextList:
|
||||
"STRING",
|
||||
{"multiline": True, "default": "[]"},
|
||||
),
|
||||
},
|
||||
"optional": {
|
||||
"display_name": (
|
||||
"STRING",
|
||||
{"multiline": False, "default": "Name of the node (optional)"},
|
||||
),
|
||||
"description": (
|
||||
"STRING",
|
||||
{"multiline": True, "default": "Description of the node (optional)"},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +39,7 @@ class ComfyUIDeployExternalTextList:
|
||||
|
||||
CATEGORY = "text"
|
||||
|
||||
def run(self, input_id, text=None):
|
||||
def run(self, input_id, text=None, display_name=None, description=None):
|
||||
text_list = []
|
||||
try:
|
||||
text_list = json.loads(text) # Assuming text is a JSON array string
|
||||
|
||||
@@ -765,6 +765,14 @@ class ComfyUIDeployExternalVideo:
|
||||
"meta_batch": ("VHS_BatchManager",),
|
||||
"vae": ("VAE",),
|
||||
"default_value": (sorted(files),),
|
||||
"display_name": (
|
||||
"STRING",
|
||||
{"multiline": False, "default": "Name of the node (optional)"},
|
||||
),
|
||||
"description": (
|
||||
"STRING",
|
||||
{"multiline": True, "default": "Description of the node (optional)"},
|
||||
),
|
||||
},
|
||||
"hidden": {
|
||||
"unique_id": "UNIQUE_ID"
|
||||
|
||||
+16
-28
@@ -56,24 +56,20 @@ retry_delay_multiplier = float(os.environ.get('RETRY_DELAY_MULTIPLIER', '2'))
|
||||
|
||||
print(f"max_retries: {max_retries}, retry_delay_multiplier: {retry_delay_multiplier}")
|
||||
|
||||
async def async_request_with_retry(method, url, disable_timeout=False, **kwargs):
|
||||
async def async_request_with_retry(method, url, **kwargs):
|
||||
global client_session
|
||||
await ensure_client_session()
|
||||
# async with aiohttp.ClientSession() as client_session:
|
||||
retry_delay = 1 # Start with 1 second delay
|
||||
initial_timeout = 5 # 5 seconds timeout for the initial connection
|
||||
|
||||
for attempt in range(max_retries):
|
||||
try:
|
||||
# Set a timeout for the initial connection
|
||||
if not disable_timeout:
|
||||
timeout = ClientTimeout(total=None, connect=initial_timeout)
|
||||
kwargs['timeout'] = timeout
|
||||
timeout = ClientTimeout(total=None, connect=initial_timeout)
|
||||
kwargs['timeout'] = timeout
|
||||
|
||||
async with client_session.request(method, url, **kwargs) as response:
|
||||
response.raise_for_status()
|
||||
if method.upper() == 'GET':
|
||||
await response.read()
|
||||
return response
|
||||
except asyncio.TimeoutError:
|
||||
logger.warning(f"Request timed out after {initial_timeout} seconds (attempt {attempt + 1}/{max_retries})")
|
||||
@@ -1154,18 +1150,18 @@ async def upload_file(prompt_id, filename, subfolder=None, content_type="image/p
|
||||
prompt_id = quote(prompt_id)
|
||||
content_type = quote(content_type)
|
||||
|
||||
target_url = f"{file_upload_endpoint}?file_name={filename}&run_id={prompt_id}&type={content_type}&version=v2"
|
||||
target_url = f"{file_upload_endpoint}?file_name={filename}&run_id={prompt_id}&type={content_type}"
|
||||
|
||||
start_time = time.time() # Start timing here
|
||||
result = await async_request_with_retry("GET", target_url, disable_timeout=True)
|
||||
result = requests.get(target_url)
|
||||
end_time = time.time() # End timing after the request is complete
|
||||
logger.info("Time taken for getting file upload endpoint: {:.2f} seconds".format(end_time - start_time))
|
||||
ok = await result.json()
|
||||
ok = result.json()
|
||||
|
||||
start_time = time.time() # Start timing here
|
||||
|
||||
async with aiofiles.open(file, 'rb') as f:
|
||||
data = await f.read()
|
||||
with open(file, 'rb') as f:
|
||||
data = f.read()
|
||||
headers = {
|
||||
# "x-amz-acl": "public-read",
|
||||
"Content-Type": content_type,
|
||||
@@ -1268,10 +1264,8 @@ async def update_file_status(prompt_id: str, data, uploading, have_error=False,
|
||||
|
||||
async def handle_upload(prompt_id: str, data, key: str, content_type_key: str, default_content_type: str):
|
||||
items = data.get(key, [])
|
||||
upload_tasks = []
|
||||
|
||||
for item in items:
|
||||
# Skipping temp files
|
||||
# # Skipping temp files
|
||||
if item.get("type") == "temp":
|
||||
continue
|
||||
|
||||
@@ -1284,28 +1278,22 @@ async def handle_upload(prompt_id: str, data, key: str, content_type_key: str, d
|
||||
elif file_extension == '.webp':
|
||||
file_type = 'image/webp'
|
||||
|
||||
upload_tasks.append(upload_file(
|
||||
await upload_file(
|
||||
prompt_id,
|
||||
item.get("filename"),
|
||||
subfolder=item.get("subfolder"),
|
||||
type=item.get("type"),
|
||||
content_type=file_type
|
||||
))
|
||||
|
||||
# Execute all upload tasks concurrently
|
||||
await asyncio.gather(*upload_tasks)
|
||||
)
|
||||
|
||||
# Upload files in the background
|
||||
async def upload_in_background(prompt_id: str, data, node_id=None, have_upload=True):
|
||||
try:
|
||||
upload_tasks = [
|
||||
handle_upload(prompt_id, data, 'images', "content_type", "image/png"),
|
||||
handle_upload(prompt_id, data, 'files', "content_type", "image/png"),
|
||||
handle_upload(prompt_id, data, 'gifs', "format", "image/gif"),
|
||||
handle_upload(prompt_id, data, 'mesh', "format", "application/octet-stream")
|
||||
]
|
||||
|
||||
await asyncio.gather(*upload_tasks)
|
||||
await handle_upload(prompt_id, data, 'images', "content_type", "image/png")
|
||||
await handle_upload(prompt_id, data, 'files', "content_type", "image/png")
|
||||
# This will also be mp4
|
||||
await handle_upload(prompt_id, data, 'gifs', "format", "image/gif")
|
||||
await handle_upload(prompt_id, data, 'mesh', "format", "application/octet-stream")
|
||||
|
||||
if have_upload:
|
||||
await update_file_status(prompt_id, data, False, node_id=node_id)
|
||||
|
||||
Reference in New Issue
Block a user