Skip to content

[CNR] Support module sytax of <node name>@<version> #1994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/types/nodeSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export const getNodeSource = (python_module?: string): NodeSource => {
badgeText: '🦊'
}
} else if (modules[0] === 'custom_nodes') {
const displayName = shortenNodeName(modules[1])
const moduleName = modules[1]
// Custom nodes installed via ComfyNodeRegistry will be in the format of
// custom_nodes.<custom node name>@<version>
const customNodeName = moduleName.split('@')[0]
const displayName = shortenNodeName(customNodeName)
return {
type: NodeSourceType.CustomNodes,
className: 'comfy-custom-nodes',
Expand Down
63 changes: 63 additions & 0 deletions tests-ui/tests/fast/nodeSource.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { getNodeSource, NodeSourceType } from '@/types/nodeSource'

describe('getNodeSource', () => {
it('should return UNKNOWN_NODE_SOURCE when python_module is undefined', () => {
const result = getNodeSource(undefined)
expect(result).toEqual({
type: NodeSourceType.Unknown,
className: 'comfy-unknown',
displayText: 'Unknown',
badgeText: '?'
})
})

it('should identify core nodes from nodes module', () => {
const result = getNodeSource('nodes.some_module')
expect(result).toEqual({
type: NodeSourceType.Core,
className: 'comfy-core',
displayText: 'Comfy Core',
badgeText: '🦊'
})
})

it('should identify core nodes from comfy_extras module', () => {
const result = getNodeSource('comfy_extras.some_module')
expect(result).toEqual({
type: NodeSourceType.Core,
className: 'comfy-core',
displayText: 'Comfy Core',
badgeText: '🦊'
})
})

it('should identify custom nodes and format their names', () => {
const result = getNodeSource('custom_nodes.ComfyUI-Example')
expect(result).toEqual({
type: NodeSourceType.CustomNodes,
className: 'comfy-custom-nodes',
displayText: 'Example',
badgeText: 'Example'
})
})

it('should identify custom nodes with version and format their names', () => {
const result = getNodeSource('custom_nodes.ComfyUI-Example@1.0.0')
expect(result).toEqual({
type: NodeSourceType.CustomNodes,
className: 'comfy-custom-nodes',
displayText: 'Example',
badgeText: 'Example'
})
})

it('should return UNKNOWN_NODE_SOURCE for unrecognized modules', () => {
const result = getNodeSource('unknown_module.something')
expect(result).toEqual({
type: NodeSourceType.Unknown,
className: 'comfy-unknown',
displayText: 'Unknown',
badgeText: '?'
})
})
})
Loading