Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@comfy_api/latest/_io.py`:
- Line 1366: The row_count calculation at the line with max(min_rows,
present_rows) does not enforce the max parameter that was serialized in
as_dict(). Read the max parameter from the List.Input object and modify the
row_count assignment to cap it so that row_count respects both the minimum
constraint (min_rows) and the maximum constraint (max parameter). This ensures
that row_count falls within the allowed range and prevents the backend from
accepting row indices beyond the specified maximum.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cd605340-c975-4ad9-8610-e97f9f52618f
📒 Files selected for processing (2)
comfy_api/latest/_io.pytests-unit/comfy_api_test/io_list_test.py
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests-unit/comfy_api_test/io_dynamic_group_test.py (1)
198-204: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression coverage for
maxoverflow.The implementation now rejects live rows beyond
max, but this error path is not covered. A small test locks the backend cap contract.Proposed test
def test_no_leftover_flat_keys(self): """Flat keys must be consumed; only the reconstructed list remains.""" inp = DynamicGroup.Input("rows", template=[Float.Input("x", default=0.0)], min=0, max=5) result = _run(inp, {"rows.0.x": 1.0, "rows.1.x": 2.0}) assert "rows.0.x" not in result assert "rows.1.x" not in result assert isinstance(result["rows"], list) + + def test_rows_beyond_max_raise(self): + inp = DynamicGroup.Input("rows", template=[Float.Input("x", default=0.0)], min=0, max=2) + + with pytest.raises(ValueError): + get_finalized_class_inputs(_make_class_inputs(inp), {"rows.2.x": 1.0})🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests-unit/comfy_api_test/io_dynamic_group_test.py` around lines 198 - 204, Add a regression test in io_dynamic_group_test around DynamicGroup.Input/_run that covers the max overflow path: create a group with a small max and submit more indexed rows than allowed, then assert the backend rejects the extra row(s) instead of reconstructing them. Reuse the existing test helpers and symbols like test_no_leftover_flat_keys, DynamicGroup.Input, and _run so the new case sits alongside the current flat-key coverage and verifies the cap contract explicitly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@comfy_api/latest/_io.py`:
- Around line 1305-1308: The DynamicGroup ID validation currently checks only
for uniqueness, but it also needs to reject any “.” characters in both group IDs
and template field IDs because slot_id encoding and path.split(".") decoding
will rebuild the wrong nested row shape. Update the DynamicGroup validation
logic around field_ids and the related DynamicGroup ID handling paths to assert
that neither the group id nor any template field id contains ".", and surface a
clear validation error before rows are encoded or decoded.
---
Nitpick comments:
In `@tests-unit/comfy_api_test/io_dynamic_group_test.py`:
- Around line 198-204: Add a regression test in io_dynamic_group_test around
DynamicGroup.Input/_run that covers the max overflow path: create a group with a
small max and submit more indexed rows than allowed, then assert the backend
rejects the extra row(s) instead of reconstructing them. Reuse the existing test
helpers and symbols like test_no_leftover_flat_keys, DynamicGroup.Input, and
_run so the new case sits alongside the current flat-key coverage and verifies
the cap contract explicitly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 7cdfa785-547c-4784-a1bd-881bbd413d05
📒 Files selected for processing (2)
comfy_api/latest/_io.pytests-unit/comfy_api_test/io_dynamic_group_test.py
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
comfy_api/latest/_io.py (1)
1376-1386: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winReject malformed DynamicGroup row keys during expansion.
loras.-1.strengthis silently ignored, whileloras.0.unknownstill incrementspresent_rows; both can drop submitted values or reconstruct blank rows. Validate canonical non-negative row indices and known template fields before counting the row.Proposed validation
# Determine how many rows are currently present by scanning live_inputs finalized_prefix = finalize_prefix(curr_prefix) + valid_field_ids = {field_id for field_id, _, _ in field_specs} present_rows = 0 for live_key in live_inputs: # Keys look like "<prefix>.<row>.<field_id>" if live_key.startswith(finalized_prefix + "."): remainder = live_key[len(finalized_prefix) + 1:] parts = remainder.split(".", 1) - if len(parts) >= 1: - try: - row_idx = int(parts[0]) - present_rows = max(present_rows, row_idx + 1) - except ValueError: - pass + if len(parts) != 2 or parts[1] not in valid_field_ids: + raise ValueError(f"Invalid DynamicGroup input key: '{live_key}'.") + try: + row_idx = int(parts[0]) + except ValueError as exc: + raise ValueError(f"Invalid DynamicGroup row index in key: '{live_key}'.") from exc + if row_idx < 0 or str(row_idx) != parts[0]: + raise ValueError(f"Invalid DynamicGroup row index in key: '{live_key}'.") + present_rows = max(present_rows, row_idx + 1)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@comfy_api/latest/_io.py` around lines 1376 - 1386, The DynamicGroup row-key handling in the live_inputs expansion logic accepts malformed keys and can count invalid rows; update the parsing in _io.py’s expansion block to validate that keys match the canonical non-negative row format before affecting present_rows. Specifically, in the loop that processes live_key and derives row_idx, reject negative or non-canonical indices and ensure the field name exists in the DynamicGroup template before incrementing present_rows, so malformed entries like loras.-1.strength or unknown fields do not influence row reconstruction.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@comfy_api/latest/_io.py`:
- Around line 1376-1386: The DynamicGroup row-key handling in the live_inputs
expansion logic accepts malformed keys and can count invalid rows; update the
parsing in _io.py’s expansion block to validate that keys match the canonical
non-negative row format before affecting present_rows. Specifically, in the loop
that processes live_key and derives row_idx, reject negative or non-canonical
indices and ensure the field name exists in the DynamicGroup template before
incrementing present_rows, so malformed entries like loras.-1.strength or
unknown fields do not influence row reconstruction.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e11c5629-30a4-4d19-aa3a-44889b562cf9
📒 Files selected for processing (1)
comfy_api/latest/_io.py
|
@Talmaj could you pleaser run a review of these changes with your agent based on |
I've done it. AI wanted to remove lots of comments and docstrings. I removed some, but decided for keeping the informative ones. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@comfy_api/latest/_io.py`:
- Around line 1380-1384: Reject malformed DynamicGroup row keys in the parsing
logic so invalid segments like loras.foo.x do not get silently ignored, and
ensure the DynamicGroup data handed to execute() always matches the promised
list[dict] contract. Update the relevant parsing/normalization code in _io.py
around the row-key handling and the code path that can leave a dict in place of
a list, and replace the silent continue/pass behavior with a clear ValueError
that surfaces the bad state immediately.
In `@tests-unit/comfy_api_test/io_dynamic_group_test.py`:
- Around line 6-10: The test setup in io_dynamic_group_test.py is shadowing a
real installed torch package by only checking sys.modules before creating the
stub. Update the torch stub guard in the test module so it first verifies torch
is truly unavailable using importlib.util.find_spec("torch") is None, and only
then injects the _torch_stub into sys.modules; keep the existing Tensor
attribute stub behavior unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 67a6cb25-6bf3-4768-a50f-85cc54060827
📒 Files selected for processing (2)
comfy_api/latest/_io.pytests-unit/comfy_api_test/io_dynamic_group_test.py
📜 Review details
⏰ Context from checks skipped due to timeout. (8)
- GitHub Check: test (macos-latest)
- GitHub Check: test (windows-latest)
- GitHub Check: test (ubuntu-latest)
- GitHub Check: test (windows-2022)
- GitHub Check: test (macos-latest)
- GitHub Check: test (ubuntu-latest)
- GitHub Check: Run Pylint
- GitHub Check: Run Pylint
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Keep imports at module scope; avoid inline imports unless they are already part of an established optional-backend probe or are needed to avoid an import cycle.
Do not add unnecessarytry/exceptblocks; use them only for optional dependency, platform, or backend capability detection when the program has a useful fallback, and prefer specific exception types when changing new code.
Remove workarounds for PyTorch versions that ComfyUI no longer officially supports; if a workaround does not have a comment naming the exact supported PyTorch version(s), remove it.
Let unsupported model formats, invalid quantization metadata, and bad states fail with clear errors instead of silently producing lower quality output.
Match the existing local style in the file you edit; this codebase tolerates long lines, simple helper functions, module-level state, and direct tensor operations when they make the code easier to follow.
Keep comments sparse and useful; strip useless comments that restate the code or describe obvious behavior, while allowing short TODOs that name the concrete missing follow-up.
Treat dtype, device placement, VRAM usage, and offloading behavior as core correctness concerns; check CPU, CUDA, ROCm, MPS, DirectML, XPU, NPU, and low VRAM implications when touching shared execution or loading code.
Prefer native ComfyUI formats and existing quantization/offload helpers over adding parallel code paths; usecomfy.quant_ops,comfy.model_management,comfy.memory_management,comfy.pinned_memory,comfy_aimdo, andcomfy-kitchenhelpers where they already solve the problem.
Use optimized comfy-kitchen ops where they improve performance without changing expected dtype, device, memory, or interface behavior.
All models should use the optimized attention function selected by ComfyUI; higher-level code must not inspect function identity, names, modules, or implementation details to decide behavior.
Apply the same opacity rule to similar patterns beyond...
Files:
tests-unit/comfy_api_test/io_dynamic_group_test.pycomfy_api/latest/_io.py
**
⚙️ CodeRabbit configuration file
**: ## Engineering Style
- Keep changes small and direct. Most fixes should touch the narrowest code path
that explains the bug, performance issue, dtype issue, model-format issue, or
user-facing behavior.- Change the least amount of files possible. A change that touches many files is
more likely to be a bad change than a good one unless the broader scope is
directly required.- Prefer practical fixes over broad architecture work. Add abstractions only
when they remove real repeated logic or match an existing ComfyUI pattern.- Prefer fewer dependencies. Do not add new dependencies to ComfyUI unless they
are absolutely necessary.- Delete obsolete code aggressively when newer infrastructure makes it useless.
Remove dead fallbacks, migration paths, unused options, debug prints, and
compatibility branches that are no longer needed. Do not leave dead branches,
unreachable code, or functions that are never called. If code is not
necessary for the current behavior, remove it.- Revert or disable problematic behavior quickly when it breaks users. It is
better to remove a broken feature path than keep a complicated partial fix.- Preserve existing APIs, node names, model-loading behavior, file layout, and
workflow compatibility unless the change is explicitly about replacing them.- Code must look hand-written for this repository. Changes that read like
generic AI-generated code will be rejected automatically: unnecessary helper
layers, vague names, boilerplate comments, defensive branches without a real
failure mode, broad rewrites, or code that ignores the local style.Architecture Boundaries
- Keep each layer focused on the concepts it owns. Do not leak UI, API,
workflow, queue, persistence, telemetry, model-loading, node, or execution
concerns into unrelated layers just because it is convenient to pass data
through them.- Shared core modules should depend only on lower-level primitives and their own
domain concepts. Highe...
Files:
tests-unit/comfy_api_test/io_dynamic_group_test.pycomfy_api/latest/_io.py
⚙️ CodeRabbit configuration file
**: IMPORTANT: Only comment on issues directly introduced by this PR's code changes.
Treat AGENTS.md as mandatory repository policy, not optional style guidance.
Flag PR changes that violate AGENTS.md even when the code is otherwise functional.
In particular, enforce architecture boundaries, dtype/device/memory rules,
interface contracts, import style, no unnecessary try/except blocks, no inline
imports, no outbound internet paths in core ComfyUI, and narrow scoped fixes.
Prefer direct findings over suggestions when a rule is violated. Only ignore
AGENTS.md when it clearly conflicts with a newer explicit maintainer instruction
in the PR.
Do NOT flag pre-existing issues in code that was merely moved, re-indented,
de-indented, or reformatted without logic changes. If code appears in the diff
only due to whitespace or structural reformatting (e.g., removing awith:block),
treat it as unchanged. Contributors should not feel obligated to address
pre-existing issues outside the scope of their contribution.
Files:
tests-unit/comfy_api_test/io_dynamic_group_test.pycomfy_api/latest/_io.py
🧠 Learnings (1)
📚 Learning: 2026-02-21T14:01:41.482Z
Learnt from: pythongosssss
Repo: Comfy-Org/ComfyUI PR: 12555
File: comfy_extras/nodes_glsl.py:719-724
Timestamp: 2026-02-21T14:01:41.482Z
Learning: In PyOpenGL, bare Python scalars can be accepted for 1-element array parameters by NumberHandler. This means you can pass an int/float directly to OpenGL texture deletion (e.g., glDeleteTextures(tex)) without wrapping in a list. Verify function-specific expectations and ensure types match what the OpenGL call expects; use explicit lists only when the API requires an array.
Applied to files:
tests-unit/comfy_api_test/io_dynamic_group_test.pycomfy_api/latest/_io.py
🔇 Additional comments (2)
comfy_api/latest/_io.py (1)
1264-1379: LGTM!Also applies to: 1385-1412, 1570-1571, 1583-1584, 1926-1945, 1981-2032, 2040-2045, 2610-2612
tests-unit/comfy_api_test/io_dynamic_group_test.py (1)
1-5: LGTM!Also applies to: 12-205
| try: | ||
| row_idx = int(parts[0]) | ||
| present_rows = max(present_rows, row_idx + 1) | ||
| except ValueError: | ||
| pass |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Reject malformed DynamicGroup row keys instead of silently continuing.
Line 1383 ignores invalid row segments like loras.foo.x, and Line 2037 can leave a dict in place of the promised list[dict]. Fail with a clear ValueError so bad DynamicGroup state does not leak into execute().
As per coding guidelines, “Do not add unnecessary try/except blocks” and “Let ... bad states fail with clear errors.” As per path instructions, AGENTS.md requires preserving interface contracts and avoiding unnecessary try/except blocks.
Proposed fix
- try:
- row_idx = int(parts[0])
- present_rows = max(present_rows, row_idx + 1)
- except ValueError:
- pass
+ if not parts[0].isdecimal():
+ raise ValueError(
+ f"DynamicGroup input '{finalized_prefix}' received invalid row key '{parts[0]}'."
+ )
+ row_idx = int(parts[0])
+ present_rows = max(present_rows, row_idx + 1)
@@
if isinstance(leaf, dict):
- try:
- sorted_rows = [leaf[k] for k in sorted(leaf.keys(), key=int)]
- container[leaf_key] = sorted_rows
- except (ValueError, TypeError):
- # Keys are not all integers; leave as-is
- pass
+ if not all(isinstance(k, str) and k.isdecimal() for k in leaf):
+ raise ValueError(f"DynamicGroup path '{list_path}' contains non-integer row keys: {list(leaf.keys())}")
+ sorted_rows = [leaf[k] for k in sorted(leaf.keys(), key=int)]
+ container[leaf_key] = sorted_rowsAlso applies to: 2033-2039
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@comfy_api/latest/_io.py` around lines 1380 - 1384, Reject malformed
DynamicGroup row keys in the parsing logic so invalid segments like loras.foo.x
do not get silently ignored, and ensure the DynamicGroup data handed to
execute() always matches the promised list[dict] contract. Update the relevant
parsing/normalization code in _io.py around the row-key handling and the code
path that can leave a dict in place of a list, and replace the silent
continue/pass behavior with a clear ValueError that surfaces the bad state
immediately.
Sources: Coding guidelines, Path instructions
| # Stub torch (type-hint only in _io.py; real torch not available in unit-test env) | ||
| if "torch" not in sys.modules: | ||
| _torch_stub = types.ModuleType("torch") | ||
| _torch_stub.Tensor = object # type: ignore[attr-defined] | ||
| sys.modules["torch"] = _torch_stub |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify whether the current test environment has torch installed but not loaded.
python - <<'PY'
import importlib.util, sys
print("torch_installed=", importlib.util.find_spec("torch") is not None)
print("torch_loaded=", "torch" in sys.modules)
PYRepository: Comfy-Org/ComfyUI
Length of output: 197
Avoid shadowing an installed torch module
This stub runs whenever torch is only unloaded, so an installed-but-unimported PyTorch gets replaced for the rest of the test session. Gate it on importlib.util.find_spec("torch") is None so only missing installs are mocked.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests-unit/comfy_api_test/io_dynamic_group_test.py` around lines 6 - 10, The
test setup in io_dynamic_group_test.py is shadowing a real installed torch
package by only checking sys.modules before creating the stub. Update the torch
stub guard in the test module so it first verifies torch is truly unavailable
using importlib.util.find_spec("torch") is None, and only then injects the
_torch_stub into sys.modules; keep the existing Tensor attribute stub behavior
unchanged.
Source: Path instructions
|
🎉 Thank you for your contribution, we really appreciate it! 🎉 Like many open source projects, we require contributors to sign our Contributor License Agreement (CLA). A CLA makes the ownership of contributions explicit, so contributors and the project share a clear understanding of how the code can be used. By signing, you:
CLAs are standard practice across major open source projects including those under the Apache Software Foundation and the Linux Foundation. Ours is based on the Apache Software Foundation's CLA. Most importantly, it would enable us to relicense the project under a more permissive license in the future, giving the project and its community greater flexibility. ✍ To sign, please post a new comment on this PR with exactly the following text: ✍ I have read and agree to the Contributor License Agreement 1 out of 2 committers have signed the CLA. |
|
Reposting feedback on this from the previous PR #14655 Comparison of results between these new LoRA nodes and the previous ones. They look close enough although some pixels are changing a bit Workflow: sdxl_lora_comparison.json
New nodes results:
Previous nodes results:
|
|
@Talmaj there are a lot of warnings in the logs that seem abnormal: |
|
recheck |
|
Superseded by #16309 |



io.DynamicGroup– repeatable widget-group inputWhat this adds
A new dynamic input type
io.DynamicGroup(COMFY_DYNAMICGROUP_V3) that lets a node declare a repeatable group of widget fields. The frontend can render N rows of those fields; the backend reconstructs them into alist[dict]before callingexecute.Previously,
Autogrowcould repeat a single widget N times andDynamicCombocould show a different sub-schema per combo value, but nothing could repeat a group of widgets.io.DynamicGroupfills that gap.Example
How it works
DynamicGroup.Inputserializes atemplate(standard V1 input dict),min, andmaxinto/object_info.COMFY_DYNAMICGROUP_V3, renders stackable rows, submits flat keys:loras.0.lora_name,loras.0.strength,loras.1.lora_name, …DynamicGroup._expand_schema_for_dynamicscanslive_inputsto determine the current row count, registers each{groupId}.{row}.{fieldId}slot inrequired/optional, and records the group root inlist_paths.build_nested_inputscollects the flat values into{0: {…}, 1: {…}}, then a post-pass converts everylist_pathsentry to a sortedlist[dict].Parameters
templatelist[WidgetInput]– the fields in each rowmin0max50Limitations
comfyui-frontend-package. Until then the schema is served correctly but rows won't stack in the UI.WidgetInputsubclasses (Combo,Float,Int,String,Boolean,Color). Plain socket inputs and nested dynamic types (DynamicGroup,Autogrow,DynamicCombo) are not allowed.io.DynamicGroupcannot be nested inside anotherio.DynamicGrouporAutogrow.Files changed
comfy_api/latest/_io.py–DynamicGroupclass,DynamicPathsDefaultValue.EMPTY_LIST,list_pathsinV3Data/get_finalized_class_inputs, list post-pass inbuild_nested_inputs, registered insetup_dynamic_input_funcs, exported in__all__tests-unit/comfy_api_test/io_dynamic_group_test.py– 18 unit tests covering schema construction, 0-row, N-row, sort order,minenforcement, partial values, and no-leftover-flat-keys