Optional Input Port and If switch

Hi everybody,

i created a node with one normal input port (I1) and one optional input port (I2). The data for the optional input is created within a if-switch (if x true -> create I2, if x false -> don't create it). I1 is available in both cases.

 

I would like the node I created to be executed depending on the if switch with or without I2 (that's why it is optional....). The problem is that if x is false and I2 is not created, all subsequent nodes are disabled (even though I2 is optional and the node could be executed without it...). When i delete the connection of I2 to my node it can be executed...

Is there any way to realize this with KNIME?

Thanks,

Jonas

 

PS: I attached an example workflow as illustration

 

Hi,

 

We are actually experiencing the same problem and wanted to ask if there are any news on this?

Did you by chance find a workaround or maybe one of the KNIME developers has a good idea by now?

The basic question is: Is it possible to stop propagation of "Inactiveness" if it only affects optional inputs?

 

Thanks a lot,

Julianus

Hi,

I was told that this is the expected behavior, I don't know a good solution to remedy this problem though. For normal table ports it may be possible to use an End If node with an empty table at one port. This means that the empty table will go into the optional input, though.

Regards,

Alexander

If I treat an optional input as an empty table, then it is possible to use an End If node, see attached. However, end if node requires both inputs to it to have the same table structure, so it may not be ideal.

 

I think you might need to set the port as an Inactive Port instance if you want downstream nodes to ignore it

Steve

Sorry, I have just re-read more carefully, and if I understand correctly, you need to change your node model implementation to implement the

InactiveBranchConsumer

interface.  For each incoming port, you can check if it is an inactive branch using:

 

if (!(inPorts[i] instanceof InactiveBranchPortObject)) {
	//Do whatever you want with active incoming port
}

You can see an example in the Vernalis community contributions.  The node model source is here, and the helper class it references is here.

Hope that helps,

Steve

1 Like