KNIME Python node archetype
Generates KNIME workflow node skeleton repository with sample code. The node executes a Python script which is included in the skeleton. The script uses dictionary for dialog options and Pandas DataFrames as input and output.
This archetype was made because the instructions to create KNIME nodes at https://tech.knime.org/developer-guide, requires interaction with Eclipse wizards. We wanted a way to start and perform node development from the command line and headless. KNIME nodes are Eclipse plugins. The Tycho Maven plugin is used to build and handle dependencies of Eclipse plugins, so we use Tycho for KNIME node building.
The Maven archetype will generate a multi-module project with the following structure:
- / - parent Maven project
- /plugin/ - code for KNIME node
- /tests/ - tests of KNIME node
- /feature/ - eclipse feature
- /p2/ - eclipse update site
The KNIME node will execute a Python script called
/plugin/src/<package>/<python script file name>.py.
See https://github.com/3D-e-Chem/knime-python-wrapper for more information how the Python Wrapper node works.
- Java >=1.8
- Maven >=3.0
The archetype is hosted on a BinTray repository. Maven does not resolve to this BinTray repository by default so it must be added.
The ~/.m2/settings.xml should contain the following profile:
<?xml version="1.0" encoding="UTF-8" ?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd"> <profiles> <profile> <id>pythonknimearchetype</id> <repositories> <repository> <id>python-knime-archetype</id> <url>https://dl.bintray.com/nlesc/knime-python-node-archetype</url> </repository> </repositories> </profile> </profiles> </settings>
The following command will generate a skeleton project
mvn archetype:generate -DarchetypeGroupId=nl.esciencecenter \ -DarchetypeArtifactId=knime-python-node-archetype \ -DarchetypeVersion=1.4.0 \ -P pythonknimearchetype
The command will ask the following questions:
- Enter the groupId
- Enter the artifactId
- Enter the name of the package under which your code will be created
- Enter the version of your project, use
x.y.z-SNAPSHOTformat (for example
1.2.3-SNAPSHOT), where x.y.z is semantic versioning.
- Enter the GitHub organization name or GitHub username
- Enter the GitHub repository name
- Enter the KNIME node name
- Enter the Python script file name (must be given without .py extension)
- Enter the required Python package name (The presence of this Python package will be checked before executing the node)
The skeleton has been generated in a sub-directory named after the artifactId in the current working directory.
The following steps are needed to get a ready to use project.
Change directory to generated code.
Make skeleton git aware, by running
Fill in all placeholders (
[Enter ... here.]) in
Commit all changes and push to GitHub
Optionally, setup Continuous Integration as described in the project README.md file.
Further instructions about generated project can be found in it's README.md file.
Generate from inside KNIME SDK
- Start up the KNIME SDK
- Install the
m2e - Maven Integration for Eclipsesoftware, (you might need to add the add the Eclipse software site which is
http://download.eclipse.org/releases/neonfor the version 3.5.1 of the KNIME SDK)
- Register the archetype catalog which contains this archetype
3.1. Goto Window > Preferences > Maven > Archetypes
3.2. Add a remove catalog with
- Create a new project based on archetype
4.1. Goto File > New > Project ... > Maven
4.2. Select Maven Project & press Next button
4.3. Use default location & press Next button
4.4. Select Catalog you added in 3.2
4.5. Select the archetype with artifact id
knime-python-node-archetype& press Next button 4.6. Fill in the form & press Finish button
- Adjust version in pom.xml
- Update CHANGELOG.md & README.md & archetype-catalog.xml
- Commit & push
- Create GitHub release
- Correct License in the Zenodo entry and publish the entry
- Deploy to Bintray, see Deploy chapter below
To deploy current version to Bintray.
- Add bintray API key to ~/.m2/settings.xml
<server> <id>bintray-nlesc-knime-python-node-archetype</id> <username>************</username> <password>********************************</password> </server>
The https://github.com/3D-e-Chem/tycho-knime-node-archetype was used as a starting point of this archetype.