|
| 1 | +Abstract Python wrapper KNIME node and helpers. |
| 2 | +Used for development of KNIME nodes calling Python scripts. |
| 3 | + |
| 4 | +[](https://travis-ci.org/3D-e-Chem/knime-python-wrapper) |
| 5 | + |
| 6 | +The nodes in Scripting>Python folder of the node repository (nodes part of the `KNIME Python integration` plugin) the end-user needs to paste Python code in a text area in the node dialog. |
| 7 | +Nodes derived from this repo will have a Python script included in their jar file and the dialog of the node will contain no source code text area. |
| 8 | +The included Python script is not editable by the end-user, but can read options from dialog like the input column name. |
| 9 | + |
| 10 | +# Usage |
| 11 | + |
| 12 | +Requirements: |
| 13 | + |
| 14 | +* KNIME SDK, https://www.knime.org, version 3.1 or higher |
| 15 | + |
| 16 | +Instructions for KNIME node developers that want to call a Python script. |
| 17 | +Several steps must be performed: |
| 18 | + |
| 19 | +[1. Add update site](#1-add-update-site) |
| 20 | +[2. Add dependency](#2-add-dependency) |
| 21 | +[3. Implement node](#3-implement-node) |
| 22 | +[4. Write tests](#4-write-tests) |
| 23 | + |
| 24 | +## 1. Add update site |
| 25 | + |
| 26 | +The releases of this repository are available in the `https://3d-e-chem.github.io/updates` update site. |
| 27 | + |
| 28 | +Configure KNIME SDK by adding the `https://3d-e-chem.github.io/updates` update site in Preferences > Install/Update > Available Software Sites. |
| 29 | + |
| 30 | +To make use of in a Tycho based project add to the `<repositories>` tag of the `pom.xml` file the following: |
| 31 | +``` |
| 32 | +<repository> |
| 33 | + <id>3d-e-chem</id> |
| 34 | + <layout>p2</layout> |
| 35 | + <url>https://3d-e-chem.github.io/updates</url> |
| 36 | +</repository> |
| 37 | +``` |
| 38 | + |
| 39 | +## 2. Add dependency |
| 40 | + |
| 41 | +To implement the node a dependency is needed for the plugin add tests. |
| 42 | +To do this add `nl.esciencecenter.e3dchem.knime.python` as a required plugin to the `plugin/META-INF/MANIFEST.MF` and `tests/META-INF/MANIFEST.MF` file. |
| 43 | + |
| 44 | +## 3. Implement node |
| 45 | + |
| 46 | +Create your node config class extended from the `nl.esciencecenter.e3dchem.python.PythonWrapperNodeConfig` class. |
| 47 | +Add fields you want to have in the node dialog and be available inside the Python script inside the `options` dictionary. |
| 48 | + |
| 49 | +Create your node model class extended from the `nl.esciencecenter.e3dchem.python.PythonWrapperNodeModel` class. |
| 50 | +Overwrite the `python_code_filename` and `required_python_packages` fields in the constructor. |
| 51 | + |
| 52 | +## 4. Write tests |
| 53 | + |
| 54 | +To run tests which execute the node it is needed to setup `KNIME Python integration` plugin. |
| 55 | +This can be done by calling `PythonWrapperTestUtils.materializeKNIMEPythonUtils()` in `@BeforeClass` method of a test case. |
| 56 | + |
| 57 | +# Build |
| 58 | + |
| 59 | +``` |
| 60 | +mvn verify |
| 61 | +``` |
| 62 | + |
| 63 | +An Eclipse update site will be made in `p2/target/repository` repository. |
| 64 | +The update site can be used to perform a local installation. |
| 65 | + |
| 66 | +# Development |
| 67 | + |
| 68 | +Development of code in this repository. |
| 69 | + |
| 70 | +Steps to get development environment setup: |
| 71 | + |
| 72 | +1. Download KNIME SDK from https://www.knime.org/downloads/overview |
| 73 | +2. Install/Extract/start KNIME SDK |
| 74 | +3. Start SDK |
| 75 | +4. Install m2e (Maven integration for Eclipse) + KNIME Python Integration |
| 76 | + |
| 77 | + 1. Goto Help > Install new software ... |
| 78 | + 2. Make sure Update site is http://update.knime.org/analytics-platform/3.1 is in the pull down list otherwise add it |
| 79 | + 3. Select --all sites-- in work with pulldown |
| 80 | + 4. Select m2e (Maven integration for Eclipse) |
| 81 | + 5. Select `KNIME Python Integration` |
| 82 | + 6. Install software & restart |
| 83 | + |
| 84 | +5. Import this repo as an Existing Maven project |
| 85 | + |
| 86 | +During import the Tycho Eclipse providers must be installed. |
| 87 | + |
| 88 | +# New release |
| 89 | + |
| 90 | +1. Update versions in pom files with `mvn org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=<version>` command. |
| 91 | +2. Manually update version of "source" feature in `p2/category.xml` file. |
| 92 | +3. Commit and push changes |
| 93 | +3. Create package with `mvn package`, will create update site in `p2/target/repository` |
| 94 | +4. Append new release to an update site |
| 95 | + 1. Make clone of an update site repo |
| 96 | + 2. Append release to the update site with `mvn install -Dtarget.update.site=<path to update site>` |
| 97 | +5. Commit and push changes in this repo and update site repo. |
0 commit comments