developing additional python nodes

Hello,

I'm trying to extend nodes from Scripting->Python (or at least use packages/classes referenced in these nodes)

I'm looking at python nodes source code here: https://github.com/knime/knime-python/tree/master/org.knime.python.nodes/src/org/knime/python/nodes

When using target platform in eclipse, only KNIME Python Integration 3.5.1.v....  is available and it does not contain the required packages that these nodes use.

eg.:

"import org.knime.python.kernel.PythonKernel" that these nodes use does not exist, while

"import org.knime.python2.kernel.PythonKernel" does etc.

 

What are the package dependencies for python node creation? And how/where can I get them?

Thanks for the response

Martin

 

Hey Martin,

sounds like a cool project.

The reason why the current target platform in eclipse does not provide org.knime.python.* is the following: the KNIME Python Integration was reworked starting in KNIME 3.4 (back then the reworked nodes could be found in KNIME Labs). In KNIME 3.5 the reworked KNIME Python Integration became the default and the old one was deprecated.

The plugins containing the old python integration are org.knime.python and org.knime.python.nodes. The reworked plugins are org.knime.python2 and org.knime.python2.nodes (note that "python2" here has nothing to do with python major version 2, but rather reflects that its version 2 of the KNIME Python Integration). The plugin org.knime.python.typeextensions is used by both, the old and the reworked KNIME Python Integration.

Given the situation I would strongly advise you to work with the reworked KNIME Python Integration (hence org.knime.python2, org.knime.python2.nodes and org.knime.python.typeextensions). These are also the packages that are under active development.

I hope I could be of help. Please do not hesitate to ask if anything remains unclear.

 

Best,

 

Clemens

Hi,

thanks for the explanation.

We are looking at the option to make input variables for our custom python scripts appear in a NodeDialog.

Not sure if that's an elegant approach but for some users it is easier to change settings via node dialog, not directly in python code. I guess it would also mean creating a whole new node for pretty much every new python script, but that could also mean that each python node would be easily recognizable (would have it's own name, dialog + default inner python script)

What's your opinion on this?

We know that there is an option to create an additional node only for setting variables and send those (flow) variables to python node, but then it's two nodes (config node + python script node), not one that can be easily shared.

Thanks for the response

Martin

I created such a node, https://github.com/3D-e-Chem/knime-sygma, it has a custom dialog and ships with a read-only python script which calls the sygma Python library.

The node is works running the old PythonKernel (org.knime.python.*) on node execute. See https://github.com/3D-e-Chem/knime-python-wrapper how the options from the dialog are passed to the Python script.

You could use these repos as inspiration.

 

Thanks a lot, that's really helpful:)