mirror of
https://github.com/Comfy-Org/ComfyUI.git
synced 2026-08-24 01:56:59 +08:00
Match PyProjectConfig shape for pyproject; add pack_id/module_name/source query filters
Two reviewer-requested improvements to GET /node_startup_errors:
1. Emit the pyproject metadata in the same {project: {...}, tool_comfy: {...}}
shape that comfy_config.config_parser.extract_node_configuration already
returns, instead of inventing a flat {pack_id, display_name, ...} bag.
API consumers can now parse the pyproject block straight through the
shared PyProjectConfig pydantic model. Empty / default-valued leaves
are pruned by a small recursive _prune_empty helper so the payload
stays compact, but nesting and field names match the source-of-truth.
2. Add optional source, module_name, and pack_id query parameters
(combined with AND) so a frontend / Manager can ask ?pack_id=foo
instead of grep'ing through the whole grouped response. pack_id
resolves against pyproject.project.name; entries without a parsed
pyproject are naturally excluded from a pack_id query.
The grouping + filtering + module_path stripping moves into
odes.filter_node_startup_errors so the route handler is a one-liner and
the helper is unit-testable without spinning up an aiohttp app.
Tests: 5 new unit tests covering each filter branch, AND-combination, and
empty-result behaviour, plus an updated pyproject-metadata assertion that
checks the nested PyProjectConfig shape, plus a focused test for the
_prune_empty helper.
This commit is contained in:
24
server.py
24
server.py
@@ -780,12 +780,26 @@ class PromptServer():
|
||||
|
||||
``module_path`` is stripped because the absolute on-disk path is
|
||||
internal detail that the frontend has no use for.
|
||||
|
||||
Optional query parameters narrow the response:
|
||||
|
||||
* ``source`` — only entries from this source bucket.
|
||||
* ``module_name`` — only entries whose module name matches exactly.
|
||||
(Folder name for directory-style packs, file
|
||||
stem for single-file modules.)
|
||||
* ``pack_id`` — only entries whose ``pyproject.project.name``
|
||||
matches exactly. Entries without a parsed
|
||||
pyproject.toml are skipped under this filter.
|
||||
|
||||
Filters are combined with AND. Filtering an empty / non-matching
|
||||
result still returns ``{}`` with HTTP 200 rather than 404 — absence
|
||||
of an error is a valid answer for this endpoint.
|
||||
"""
|
||||
grouped: dict[str, dict[str, dict]] = {}
|
||||
for entry in nodes.NODE_STARTUP_ERRORS.values():
|
||||
source = entry.get("source", "custom_nodes")
|
||||
public_entry = {k: v for k, v in entry.items() if k != "module_path"}
|
||||
grouped.setdefault(source, {})[entry["module_name"]] = public_entry
|
||||
grouped = nodes.filter_node_startup_errors(
|
||||
source=request.query.get("source"),
|
||||
module_name=request.query.get("module_name"),
|
||||
pack_id=request.query.get("pack_id"),
|
||||
)
|
||||
return web.json_response(grouped)
|
||||
|
||||
@routes.get("/api/jobs")
|
||||
|
||||
Reference in New Issue
Block a user