Skip to content

Commit 6507679

Browse files
committed
Split out monolith node into smaller nodes
1 parent 8a8dc96 commit 6507679

12 files changed

+816
-307
lines changed

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "ComfyUI-Prompt-Companion"
7-
version = "0.0.6"
7+
version = "0.0.7"
88
description = "A node that lets you save and reuse parts of prompts (embeddings, quality keywords, and so on.)"
99
authors = [
1010
{name = "John Cantu", email = "jfcantu@gmail.com"}
@@ -21,11 +21,13 @@ dependencies = [
2121

2222
[project.optional-dependencies]
2323
dev = [
24+
"aiohttp", # for testing API handlers
2425
"bump-my-version",
2526
"coverage", # testing
2627
"mypy", # linting
2728
"pre-commit", # runs linting on commit
2829
"pytest", # testing
30+
"pytest-asyncio", # for async test support
2931
"ruff", # linting
3032
]
3133

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ testpaths = tests
33
python_files = test_*.py
44
python_classes = Test*
55
python_functions = test_*
6+
pythonpath = ../../
67
addopts = -v --tb=short --strict-markers
78
markers =
89
asyncio: marks tests as async tests

src/api_handlers.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ async def get_prompt_additions(request: web.Request) -> web.Response:
129129
JSON response with prompt additions and groups data
130130
"""
131131
try:
132-
print(f"[ComfyUI-Prompt-Companion] get_prompt_additions called, PROMPT_ADDITIONS: {PROMPT_ADDITIONS}")
133132
if PROMPT_ADDITIONS is None:
134133
return create_error_response(
135134
"Prompt additions not initialized",
@@ -143,7 +142,6 @@ async def get_prompt_additions(request: web.Request) -> web.Response:
143142
)
144143
except Exception as e:
145144
logging.error(f"Server error retrieving prompt additions: {e}")
146-
print(f"[ComfyUI-Prompt-Companion] Exception in get_prompt_additions: {e}")
147145
return create_error_response(
148146
"Failed to retrieve prompt additions",
149147
["An unexpected error occurred"],
@@ -174,12 +172,12 @@ async def write_prompt_addition(request: web.Request) -> web.Response:
174172
# Input validation
175173
is_valid, message, errors = validate_request_json(prompt_addition_data)
176174
if not is_valid:
177-
return create_error_response(message, errors, status=400)
175+
return create_error_response(message or "Validation error", errors or [], status=400)
178176

179177
# Validate required fields
180178
is_valid, message, errors = validate_name_field(prompt_addition_data)
181179
if not is_valid:
182-
return create_error_response(message, errors, status=400)
180+
return create_error_response(message or "Validation error", errors or [], status=400)
183181

184182
name = prompt_addition_data["name"].strip()
185183

@@ -311,12 +309,12 @@ async def write_prompt_group(request: web.Request) -> web.Response:
311309
# Input validation
312310
is_valid, message, errors = validate_request_json(prompt_group_data)
313311
if not is_valid:
314-
return create_error_response(message, errors, status=400)
312+
return create_error_response(message or "Validation error", errors or [], status=400)
315313

316314
# Validate required fields
317315
is_valid, message, errors = validate_name_field(prompt_group_data)
318316
if not is_valid:
319-
return create_error_response(message, errors, status=400)
317+
return create_error_response(message or "Validation error", errors or [], status=400)
320318

321319
name = prompt_group_data["name"].strip()
322320

src/extension_config.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,5 @@ def prompt_groups(self) -> dict[int, PromptGroup]:
264264
if os.path.exists(CONFIG_PATH):
265265
with open(CONFIG_PATH, "r") as config_file:
266266
config_data = json.load(config_file)
267-
print(f"[ComfyUI-Prompt-Companion] Loaded config from: {CONFIG_PATH}")
268-
else:
269-
print(f"[ComfyUI-Prompt-Companion] No existing config found, will create new config at: {CONFIG_PATH}")
270267

271268
PROMPT_ADDITIONS = ExtensionConfig(config_data)

src/nodes.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
# Register API endpoints only when running in ComfyUI
2020
try:
2121
from server import PromptServer
22-
print("[ComfyUI-Prompt-Companion] PromptServer imported successfully")
2322

2423
# Import API handlers from separate module
2524
from api_handlers import (
@@ -30,11 +29,9 @@
3029
write_prompt_group,
3130
delete_prompt_group
3231
)
33-
print("[ComfyUI-Prompt-Companion] API handlers imported successfully")
3432

3533
# Get the routes instance for registering API endpoints
3634
routes = PromptServer.instance.routes
37-
print(f"[ComfyUI-Prompt-Companion] Got routes instance: {routes}")
3835

3936
# Register API endpoints using decorator pattern
4037
PromptServer.instance.routes.get("/prompt-companion/prompt-addition")(get_prompt_additions)
@@ -44,13 +41,11 @@
4441
PromptServer.instance.routes.post("/prompt-companion/prompt-group")(write_prompt_group)
4542
PromptServer.instance.routes.delete("/prompt-companion/prompt-group/{prompt_group_id}")(delete_prompt_group)
4643

47-
print(f"[ComfyUI-Prompt-Companion] API routes registered successfully - Total routes: {len(routes)}")
4844

4945
except ImportError as e:
5046
# Running outside ComfyUI - routes won't be registered
51-
print(f"[ComfyUI-Prompt-Companion] Running outside ComfyUI - API routes not registered: {e}")
47+
pass
5248
except Exception as e:
53-
print(f"[ComfyUI-Prompt-Companion] Error during route registration: {e}")
5449
import traceback
5550
traceback.print_exc()
5651

0 commit comments

Comments
 (0)