Simple trick for “swapping” out nodes

I just wanted to post one of my “user interface hacks” in case others are struggling with swapping out existing nodes with multiple connections across very large workflows. Since there is no option to “swap” out nodes, I use components to replace single nodes (or a collection of nodes) while leaving all of the existing connections in place.

Turn your node into a “component”, then open the component and swap out your node / save, then go back to your workflow and “expand” your component.

This maintains all of your node connections and avoids what can turn into a nightmare of zoom adjustments / node moving / connection drawing on bigger projects.

I am sure there are plenty of users who have discovered this workaround, but I haven’t seen it of the forums so I wanted to throw it out there in case it helps someone.

4 Likes

FYI - I also use this to “insert” a node behind another that has multiple connections. Much easier than redrawing connections across large workflows.

2 Likes

Hi @iCFO , that sounds like a useful tip, but when you say “swap out a node”, do you mean replace an existing node on the workflow with a different node (e.g. from the palette ) whilst keeping the node connections intact?

If so, it was only recently that I discovered you can do this using drag and drop… a very specific drag and drop.

Say I have the following:

and I want to replace the central String Manipulation node with a String to Number node.

I find the String to Number node in the Node repository:

Then drag it onto the String Manipulation node.

image

At the exact point that I have dragged onto the String Manipulation node, the node’s colour “inverts”

image

When it is in this altered-state, I drop the replacement node…

and KNIME swaps the nodes whilst retaining connections :slight_smile:

6 Likes

@takbb - I hadn’t found that change. Thanks!

The component trick is a good hack for inserting a node behind one that has multiple connections, while keeping the connections in place.

1 Like

You guys are really something! :+1: :+1: :+1:

Yes I can that being useful, and it’s amazing how useful components can be even when not actually doing the things they were designed for!

When I started playing with KNIME, I would have this kind of situation

where a load of database things (not just query readers) would hang off a connection to the DEV database. And then, I’d want to do it using the UAT database and so on. Obviously I could reconfigure the connection each time but that’s a right pain.

So I moved on to attaching a DB SQL Executor containing a dummy query to the Connector, and then connecting everything else to the DB SQL Executor.

Then all I had to do was switch out the DB Connector that was attached to the DB SQL Executor.

To improve readability, I eventually adopted a suggestion of @bruno29a for creating “dummy nodes” using components. He has a “dummy node” data component where the component literally passes the input data port to the output data port with nothing in between. Great idea… so I created a similar DB Session Passthrough component to do the same job but different ports, giving “clearer intent” in my workflows.

The passthrough component does exactly what it says on the tin:

image

All this, so I didn’t have to “rewire” my db connections! :open_mouth:

(Ok, so I subsequently created a single component that contains a selectable connection to all three databases, but that’s a story for another day :wink: )

5 Likes

There’s also the ready-to-use NoOp nodes, which do exactly, well … nothing when executed, but keeping connections in the workflow tidy and allowing to easily drag 1:many connections around:

There’s one among them which can be configured to any kind of port type:

9 Likes

I use the “dummy node” type tricks as well, but that approach only works when it was added in advance.

The component trick can be used to insert those dummy nodes after the fact without the connection hassles.

The dummy node that @takbb is referring to can be found at:

The advantage of using component is that you can change the input and output port types are you wish, so it’s usable for any ports.

Nice sets of noOps nodes there @qqilihq

1 Like

Not really. You can drag and drop the component on the node you want to replace, and the component will replace that node. This is actually demonstrated by @takbb in this post with the String Manipulation:

@bruno29a - But not place it after an existing node keeping all of the trailing connections in place. I was referencing “inserting” a dummy node after an existing one on that post (which is my typical use case for a dummy node), not replacing altogether.

I guess you could copy the node being replaced and then re-insert it as long as the drag / replace trick keeps the copied node in memory…

I marked @takbb post as a built in faster solution for the node “swapping”.

When it comes to “inserting” a node behind another with the new node retaining all of the earlier nodes output connections, I will stick with the component trick (or possibly the copy / swap / paste technique in the post above) for the time being.

Thanks everyone! Great info as always!

2 Likes

Thanks @qqilihq , that’s a useful set I hadn’t spotted before.

I really enjoy these discussion topics. they make a nice change from the general “call for help” posts on the forum and there is invariably something interesting to learn, or a different approach to be discovered! Thanks @iCFO and @bruno29a as always!

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.