Replace CLIPType if with getattr #7589
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is mostly a small change that replaces the long if statement with a getattr where the common name (e.g. "wan") gets mapped to the enum (
CLIPType.WAN
) in the clip loader nodes.The main benefit of this is assuring that the common name actually matches the enum, so that downstream nodes don't need to keep their own mapping for custom clip loader nodes. (ref: city96/ComfyUI-GGUF#246 (comment))
Test for the current values in the single / dual clip loader node. Only odd one out is SDXL which doesn't have an enum and instead uses "stabe_diffusion". The logic in the single clip loader node already defaults to
CLIPType.STABLE_DIFFUSION
, so I just extended this to the dual clip loader as well.