Conversation
📝 WalkthroughWalkthroughA 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 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
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
📒 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)) |
There was a problem hiding this comment.
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.
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.