You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 23, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+36-14Lines changed: 36 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,12 +20,12 @@ Requirements:
20
20
Instructions for KNIME node developers that want to call a Python script.
21
21
Several steps must be performed:
22
22
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)
27
27
28
-
## 1. Add update site
28
+
## Add update site
29
29
30
30
The releases of this repository are available in the `https://3d-e-chem.github.io/updates` update site.
31
31
@@ -40,14 +40,35 @@ To make use of in a Tycho based project add to the `<repositories>` tag of the `
40
40
</repository>
41
41
```
42
42
43
-
## 2. Add dependency
43
+
## Add dependency
44
44
45
45
To implement the node a dependency is needed for the plugin add tests.
46
46
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.
47
47
48
-
## 3. Implement node
48
+
## Implement
49
+
50
+
### Config
49
51
50
52
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
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
+
51
72
Inside Python script the following variables are special:
52
73
53
74
*`options`, dictionary filled from Java with PythonWrapperNodeConfig.getOptionsValues() method, to read from
@@ -56,16 +77,17 @@ Inside Python script the following variables are special:
56
77
*`flow_variables`, dictionary of flow variables, to get or put key/value pairs
57
78
*`flow_variables['warning_message']`, if key exists then value will be set as warning message of node
58
79
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
61
83
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.
64
86
65
-
## 4. Write tests
87
+
## Write tests
66
88
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.
0 commit comments