Coder Social home page Coder Social logo

Comments (6)

rgthree avatar rgthree commented on August 14, 2024 1

Hmmm. I'm honestly a little conflicted. The Any Switch was really built to be used with muting. So, if you didn't want an empty string to be chosen, you would mute that node.

It is true that I added support for an empty Context being skipped if passed in (at least for the Context Switch, not sure if it works that way for the Any Switch if using Contexts). But I worry a bit about changing the behavior here, especially now that it's been out for so long...

While empty string may seem to make sense, I could see someone who uses an empty string as the last value so it always passes a valid string if others a muted. I could also think this opens the question up to empty lists being ignored, or a 0 number, etc.

For now, I think I'm erring on the side of not changing the existing behavior and having it rely on muting as the primary switching.

from rgthree-comfy.

rgthree avatar rgthree commented on August 14, 2024 1

8c92a8a adds support for dynamic number of inputs to Any Switch!

from rgthree-comfy.

gshawn3 avatar gshawn3 commented on August 14, 2024

Oh, I also meant to mention: With the recent commit 45781c3, Context Switch nodes now support a dynamic number of inputs. That's a nice upgrade!

This would also be a very useful feature for the Any Switch node. I think that's the only way the current node can still be improved, if it started with just two inputs and then added/removed inputs dynamically as needed.

from rgthree-comfy.

rgthree avatar rgthree commented on August 14, 2024

Separately, dynamic inputs for the any switch should be easy. Good idea

from rgthree-comfy.

gshawn3 avatar gshawn3 commented on August 14, 2024

Hmmm. I'm honestly a little conflicted. The Any Switch was really built to be used with muting. So, if you didn't want an empty string to be chosen, you would mute that node.

It is true that I added support for an empty Context being skipped if passed in (at least for the Context Switch, not sure if it works that way for the Any Switch if using Contexts). But I worry a bit about changing the behavior here, especially now that it's been out for so long...

While empty string may seem to make sense, I could see someone who uses an empty string as the last value so it always passes a valid string if others a muted. I could also think this opens the question up to empty lists being ignored, or a 0 number, etc.

For now, I think I'm erring on the side of not changing the existing behavior and having it rely on muting as the primary switching.

That makes sense and it's probably what I would do as well, considering the node has been out for a while and this change would break backwards compatibility.

Thank you for implementing dynamic number of inputs!

from rgthree-comfy.

gshawn3 avatar gshawn3 commented on August 14, 2024

I think this is worth documenting here, in case it's useful to someone in the future:

With the dynamic number of inputs feature, the Any Switch node now prunes its inputs whenever any connections are changed. When determining whether an input should be pruned, the node checks if that input has a link:

if (!node.inputs[i]?.link) {

If like me, you use the Any Switch extensively with "virtual" links such as those created by Anything Everywhere, that will cause those inputs to be dropped. You'll need to add an extra condition or two at the line above.

from rgthree-comfy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.