Skip to content
This repository was archived by the owner on Nov 23, 2023. It is now read-only.

Commit 9a7c1d8

Browse files
committed
Group usage steps per class/file
1 parent 7cf3f44 commit 9a7c1d8

File tree

1 file changed

+36
-14
lines changed

1 file changed

+36
-14
lines changed

README.md

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ Requirements:
2020
Instructions for KNIME node developers that want to call a Python script.
2121
Several steps must be performed:
2222

23-
[1. Add update site](#1-add-update-site)
24-
[2. Add dependency](#2-add-dependency)
25-
[3. Implement node](#3-implement-node)
26-
[4. Write tests](#4-write-tests)
23+
1. [Add update site](#1-add-update-site)
24+
2. [Add dependency](#2-add-dependency)
25+
3. [Implement](#3-implement)
26+
4. [Write tests](#4-write-tests)
2727

28-
## 1. Add update site
28+
## Add update site
2929

3030
The releases of this repository are available in the `https://3d-e-chem.github.io/updates` update site.
3131

@@ -40,14 +40,35 @@ To make use of in a Tycho based project add to the `<repositories>` tag of the `
4040
</repository>
4141
```
4242

43-
## 2. Add dependency
43+
## Add dependency
4444

4545
To implement the node a dependency is needed for the plugin add tests.
4646
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.
4747

48-
## 3. Implement node
48+
## Implement
49+
50+
### Config
4951

5052
Create your node config class extended from the `nl.esciencecenter.e3dchem.python.PythonWrapperNodeConfig` class.
53+
54+
Overwrite the constructor to add required Python modules with the `addRequiredModule("<module name>")` method.
55+
56+
PythonWrapperNodeConfig class are configured for a single input table called `input_table` and a single output table called `output_table`.
57+
To change the the number and names of input and/or output tables, override the constructor.
58+
59+
### Dialog
60+
61+
In your nodes dialog the Python options panel should be added by adding the following to the dialog constructor
62+
```java
63+
pythonOptions = new PythonOptionsPanel<PredictMetabolitesConfig>();
64+
addTab("Python options", pythonOptions);
65+
```
66+
67+
To save the Python options to disk you must call the `pythonOptions.saveSettingsTo(config)` followed by `config.saveTo(settings)` in the `save*To()` method of the dialog.
68+
To load the Python options from disk you must call the `config.loadFrom(settings)` followed by `pythonOptions.loadSettingsFrom(config)` in the `load*From()` methods of the dialog.
69+
70+
### Python script
71+
5172
Inside Python script the following variables are special:
5273

5374
* `options`, dictionary filled from Java with PythonWrapperNodeConfig.getOptionsValues() method, to read from
@@ -56,16 +77,17 @@ Inside Python script the following variables are special:
5677
* `flow_variables`, dictionary of flow variables, to get or put key/value pairs
5778
* `flow_variables['warning_message']`, if key exists then value will be set as warning message of node
5879

59-
Create your node model class extended from the `nl.esciencecenter.e3dchem.python.PythonWrapperNodeModel` class.
60-
Overwrite the `python_code_filename` and `required_python_packages` fields in the constructor.
80+
The Python script should be located in same directory as the model.
81+
82+
### Model
6183

62-
PythonWrapperNodeConfig and PythonWrapperNodeModel class are setup for a single input table called `input_table` and a single output table called `output_table`.
63-
To change the the number and names of input and/or output tables, create sub-classes from them and override the constructor in both sub-classes.
84+
Create your node model class extended from the `nl.esciencecenter.e3dchem.python.PythonWrapperNodeModel` class.
85+
Overwrite the `python_code_filename` fields in the constructor, this is the name of the Python script.
6486

65-
## 4. Write tests
87+
## Write tests
6688

67-
To run tests which execute the node it is needed to setup `KNIME Python integration` plugin.
68-
This can be done by calling `PythonWrapperTestUtils.materializeKNIMEPythonUtils()` in `@BeforeClass` method of a test case.
89+
To run tests which execute the node a call to `PythonWrapperTestUtils.materializeKNIMEPythonUtils()` is required
90+
this will add the KNIME-Python utility scripts to the Python path.
6991

7092
# Build
7193

0 commit comments

Comments
 (0)