Dynamic ports in Python-based nodes

Hi fellow KNIMErs,

I am currently exploring the Python API of KAP v4.7 to convert a set of components into a full-fledged Python extension.

One of the nodes that I intend to create requires the option to dynamically add and remove table input ports in KAP – think the dynamic ports functionality of standard nodes like the Excel Writer.

I take it from the documentation, however, that each input port must be defined with a @knext.input_table decorator.

I faced the same limitation when I built the components that I now want to bring into an extension. My workaround then was to have the user do a bit of preprocessing upstream: append an identifier column to all input tables and concatenate them. This data was fed to the component via a single table input port and then split internally by the identifier column again.

While I could implement this logic in the Python node’s execute method too, I would of course prefer to have actual dynamic input ports.

So, here go my questions:

  1. How can dynamic ports be achieved with the Python API?
  2. If it is not feasible at the moment, where is it on the roadmap?

Any comments and pointers will be appreciated!

Cheers

Hi @DerMaxdorfer,
Thanks for trying out our pure-Python KNIME extension development API!

You are right, dynamic input ports are not yet available in pure-Python nodes. We have had this feature request pop up more and more recently, so we want to address it soon. However, as our summer release of KNIME AP is right around the corner, dynamic ports will not be available with the next release yet, unfortunately.

So for the time being you might have to fall back to the same workaround as for your components.

Hope that helps!
Carsten

3 Likes

Thanks for clarifying, @carstenhaubold! I just wanted to make sure that I had not missed anything.

It is good to know that this topic is already on your radar. Keep up the great work!

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