How to create a custom node that returns a sampler ?
Here is what I have right now:
class BasicParameters:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, ),
"scheduler": (comfy.samplers.KSampler.SCHEDULERS, ),
"steps": ("INT", {"default": 20, "min": 1, "max": 10000}),
"hires_steps": ("INT", {"default": 20, "min": 1, "max": 10000}),
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0, "step":0.1, "round": 0.01}),
}
}
RETURN_TYPES = ("COMBO,STRING", "COMBO, STRING", "INT", "INT", "FLOAT")
RETURN_NAMES = ("sampler_name", "scheduler_name", "steps", "hires steps", "cfg")
FUNCTION = "select"
CATEGORY = "sampling"
def select(self, sampler_name, scheduler_name, steps, hires_steps, cfg):
return (sampler_name, scheduler_name, steps, hires_steps, cfg)
I've tried to use RETURN_TYPES = ("COMBO", ....) instead of "COMBO,STRING", but apparently, the frontend requires that extra ,STRING in order to accept the connection.
But then, here is what I get when I'm trying to generate:
Return type mismatch between linked nodes: sampler_name, COMBO,STRING != COMBO
So, how do you do this properly ?
Shouldn't the return type not be a tuple for the sampler and scheduler?
RETURN_TYPES = (("COMBO", "STRING"), ("COMBO", "STRING"), "INT", "INT", "FLOAT")
RETURN_NAMES = ("sampler_name", "scheduler_name", "steps", "hires steps", "cfg")
You can try:
RETURN_TYPES = ("COMBO", "COMBO", "INT", "INT", "FLOAT")
# ...
return ([sampler_name],[scheduler_name], steps, hires_steps, cfg)
This is old, but I recently came across this same situation. The way I solved was by just using comfy.samplers.KSampler.SAMPLERS in the RETURN_TYPES.
It would look like this:
RETURN_TYPES = (comfy.samplers.KSampler.SAMPLERS, comfy.samplers.KSampler.SCHEDULERS, "INT", "INT", "FLOAT")