Merge pull request #39 from ComfyAssets/feat/local_image
style(core): remove unused imports and adjust formatting
This commit is contained in:
@@ -4,8 +4,7 @@ This module provides the central registration system for all KikoTools nodes.
|
||||
"""
|
||||
|
||||
import importlib
|
||||
import os
|
||||
from typing import Dict, List, Any, Optional
|
||||
from typing import Dict, Any
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -74,7 +73,7 @@ class ToolRegistry:
|
||||
attr.SETTINGS,
|
||||
)
|
||||
|
||||
except ImportError as e:
|
||||
except ImportError:
|
||||
# Tool might not have a node.py file yet
|
||||
pass
|
||||
|
||||
|
||||
+11
-11
@@ -118,7 +118,7 @@ class SettingsRegistry:
|
||||
js_lines.append(f" // {tool_settings.display_name} settings")
|
||||
|
||||
for setting in tool_settings.settings:
|
||||
js_lines.append(f" app.ui.settings.addSetting({{")
|
||||
js_lines.append(" app.ui.settings.addSetting({")
|
||||
js_lines.append(f' id: "{setting.id}",')
|
||||
js_lines.append(f' name: "{setting.name}",')
|
||||
js_lines.append(
|
||||
@@ -130,16 +130,16 @@ class SettingsRegistry:
|
||||
js_lines.append(f' tooltip: "{setting.description}",')
|
||||
|
||||
if setting.type == "combo" and setting.options:
|
||||
js_lines.append(f" options: (value) => {{")
|
||||
js_lines.append(" options: (value) => {")
|
||||
js_lines.append(
|
||||
f" const options = {json.dumps(setting.options)};"
|
||||
)
|
||||
js_lines.append(f" return options.map(opt => ({{")
|
||||
js_lines.append(f" value: opt,")
|
||||
js_lines.append(f" text: String(opt),")
|
||||
js_lines.append(f" selected: opt === value")
|
||||
js_lines.append(f" }}));")
|
||||
js_lines.append(f" }},")
|
||||
js_lines.append(" return options.map(opt => ({")
|
||||
js_lines.append(" value: opt,")
|
||||
js_lines.append(" text: String(opt),")
|
||||
js_lines.append(" selected: opt === value")
|
||||
js_lines.append(" }));")
|
||||
js_lines.append(" }},")
|
||||
|
||||
if setting.type == "number":
|
||||
if setting.min_value is not None:
|
||||
@@ -150,11 +150,11 @@ class SettingsRegistry:
|
||||
js_lines.append(f" step: {setting.step},")
|
||||
|
||||
if setting.on_change:
|
||||
js_lines.append(f" onChange(value) {{")
|
||||
js_lines.append(" onChange(value) {")
|
||||
js_lines.append(f" {setting.on_change}")
|
||||
js_lines.append(f" }}")
|
||||
js_lines.append(" }")
|
||||
|
||||
js_lines.append(f" }});")
|
||||
js_lines.append(" }});")
|
||||
js_lines.append("")
|
||||
|
||||
js_lines.extend([" }", "});", ""])
|
||||
|
||||
@@ -41,8 +41,6 @@ class SimpleBatchPromptsNode(ComfyAssetsBaseNode):
|
||||
|
||||
def get_next_prompt(self, prompt_file: str) -> Tuple[str, str, int]:
|
||||
"""Get the next prompt in sequence."""
|
||||
global GLOBAL_COUNTER
|
||||
|
||||
# Resolve file path
|
||||
if not os.path.isabs(prompt_file):
|
||||
try:
|
||||
@@ -50,7 +48,7 @@ class SimpleBatchPromptsNode(ComfyAssetsBaseNode):
|
||||
|
||||
input_dir = folder_paths.get_input_directory()
|
||||
full_path = os.path.join(input_dir, prompt_file)
|
||||
except:
|
||||
except ImportError:
|
||||
full_path = os.path.abspath(prompt_file)
|
||||
else:
|
||||
full_path = prompt_file
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"""State management for batch prompts using file persistence."""
|
||||
|
||||
import os
|
||||
import json
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
@@ -22,7 +21,7 @@ class StateManager:
|
||||
try:
|
||||
with open(self.state_file, "r") as f:
|
||||
return json.load(f)
|
||||
except:
|
||||
except (json.JSONDecodeError, IOError):
|
||||
pass
|
||||
return {}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Logic for DisplayAny node - displays any input value or tensor shape."""
|
||||
|
||||
from typing import Any, List, Union
|
||||
from typing import Any, List
|
||||
|
||||
|
||||
def get_tensor_shapes(input_value: Any) -> List[List[int]]:
|
||||
@@ -54,7 +54,7 @@ def format_display_value(input_value: Any, mode: str = "raw value") -> str:
|
||||
|
||||
if isinstance(input_value, (dict, list)):
|
||||
return json.dumps(input_value, indent=2)
|
||||
except:
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
|
||||
return str(input_value)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""DisplayAny node for ComfyUI - displays any input value or tensor information."""
|
||||
|
||||
from typing import Any, Dict, Tuple
|
||||
from typing import Any, Dict
|
||||
|
||||
from ...base import ComfyAssetsBaseNode
|
||||
from .logic import format_display_value, validate_display_mode
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
from typing import List, Dict, Any, Tuple, Optional
|
||||
import random
|
||||
import time
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
"""Logic module for Plot Parameters node."""
|
||||
|
||||
from typing import List, Dict, Any, Tuple, Optional
|
||||
from typing import List, Dict, Tuple
|
||||
import math
|
||||
import textwrap
|
||||
import logging
|
||||
import torch
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -204,8 +203,6 @@ def format_parameter_text(param: Dict, mode: str = "full") -> str:
|
||||
if "lora" in param and param["lora"]:
|
||||
lora_path = param["lora"]
|
||||
# Extract just the filename and immediate parent directory for better readability
|
||||
import os
|
||||
|
||||
path_parts = lora_path.replace("\\", "/").split("/")
|
||||
if len(path_parts) > 2:
|
||||
# Show parent directory and filename
|
||||
|
||||
@@ -38,7 +38,6 @@ from .logic import (
|
||||
filter_changing_params,
|
||||
format_parameter_text,
|
||||
wrap_prompt_text,
|
||||
calculate_text_dimensions,
|
||||
calculate_grid_dimensions,
|
||||
validate_plot_parameters,
|
||||
)
|
||||
@@ -178,7 +177,7 @@ class PlotParametersNode(ComfyAssetsBaseNode):
|
||||
|
||||
try:
|
||||
font = ImageFont.truetype(font_path, font_size)
|
||||
except:
|
||||
except (IOError, OSError):
|
||||
logger.warning(f"Could not load font from {font_path}, using default")
|
||||
font = ImageFont.load_default()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Logic module for Sampler Select Helper node."""
|
||||
|
||||
from typing import List, Dict, Any
|
||||
from typing import List, Dict
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Logic module for Scheduler Select Helper node."""
|
||||
|
||||
from typing import List, Dict, Any
|
||||
from typing import List, Dict
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Logic module for Text Encode Sampler Params node."""
|
||||
|
||||
from typing import List, Dict, Any, Optional
|
||||
from typing import List, Dict, Any
|
||||
import re
|
||||
import logging
|
||||
|
||||
@@ -69,9 +69,9 @@ def encode_prompts(prompts: List[str], clip_encoder) -> List[Any]:
|
||||
try:
|
||||
conditioning = encoder.encode(clip_encoder, prompt)[0]
|
||||
encoded.append(conditioning)
|
||||
logger.debug(f"Encoded prompt {i+1}/{len(prompts)}")
|
||||
logger.debug(f"Encoded prompt {i + 1}/{len(prompts)}")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to encode prompt {i+1}: {e}")
|
||||
logger.error(f"Failed to encode prompt {i + 1}: {e}")
|
||||
encoded.append(None)
|
||||
|
||||
encoded = [e for e in encoded if e is not None]
|
||||
|
||||
Reference in New Issue
Block a user