Skip to content

Add test that each model has unique identifiers CORE-134#13654

Open
Talmaj wants to merge 1 commit intomasterfrom
CORE-134
Open

Add test that each model has unique identifiers CORE-134#13654
Talmaj wants to merge 1 commit intomasterfrom
CORE-134

Conversation

@Talmaj
Copy link
Copy Markdown
Contributor

@Talmaj Talmaj commented May 1, 2026

This is a safeguard that we don't by mistake define the same identifiers for different models.

To test that it works, I've manually duplicated unet_config and required_keys for two models, to which we get a nice output which models have problematic identifiers.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

📝 Walkthrough

Walkthrough

A unit test was added to the model detection test suite to validate model uniqueness. The test introduces a helper function that converts nested configuration structures into hashable forms, enabling comparison of models based on their unet_config and required_keys attributes. The test then iterates through all registered models and ensures that no two models share an identical combination of these configuration properties, which would create ambiguity in detection logic.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding a test to ensure each model has unique identifiers, with a specific ticket reference.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose of the test and how it was validated.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests-unit/comfy_test/model_detection_test.py`:
- Line 136: The key used for deduping models currently freezes
model.required_keys including values, which can miss collisions because
matches() only considers membership; update the normalization to freeze only the
key names (e.g., use the set or list of model.required_keys.keys()) so the key
becomes (_freeze(model.unet_config), _freeze(<only the required key names>)) and
thereby align with matches() semantics; modify the use of _freeze around
model.required_keys in the code that builds the key to use just the keys instead
of the full dict.
🪄 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: 68c5791b-fa9a-4675-ab15-68a39c994e6a

📥 Commits

Reviewing files that changed from the base of the PR and between cf9cbec and 3b1c60b.

📒 Files selected for processing (1)
  • tests-unit/comfy_test/model_detection_test.py

models = comfy.supported_models.models
groups = defaultdict(list)
for model in models:
key = (_freeze(model.unet_config), _freeze(model.required_keys))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Align required_keys normalization with matches() semantics (keys-only).

At Line 136, using _freeze(model.required_keys) can miss collisions when required_keys is a dict with same keys but different values. matches() only uses required-key membership, so this should normalize to key names only.

Suggested patch
         groups = defaultdict(list)
         for model in models:
-            key = (_freeze(model.unet_config), _freeze(model.required_keys))
+            required_keys_key = (
+                frozenset(model.required_keys.keys())
+                if isinstance(model.required_keys, dict)
+                else frozenset(model.required_keys)
+            )
+            key = (_freeze(model.unet_config), required_keys_key)
             groups[key].append(model.__name__)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests-unit/comfy_test/model_detection_test.py` at line 136, The key used for
deduping models currently freezes model.required_keys including values, which
can miss collisions because matches() only considers membership; update the
normalization to freeze only the key names (e.g., use the set or list of
model.required_keys.keys()) so the key becomes (_freeze(model.unet_config),
_freeze(<only the required key names>)) and thereby align with matches()
semantics; modify the use of _freeze around model.required_keys in the code that
builds the key to use just the keys instead of the full dict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants