This repository is maintained by the KNIME Team Rakete.
It provides a template for creating KNIME Python extensions.
This repository contains a template KNIME Python Extensions. The code is organized as follows:
.
├── icons
│ └── icon.png
├── src
│ ├── __init__.py
│ └── extension.py
├── demo
│ └── Example_with_Python_node.knwf
├── tests
│ ├── conftest.py
│ └── test_extension.py
├── knime.yml
├── pixi.toml
├── config.yml
│── LICENSE.TXT
└── README.md
You can find instructions on how to work with our code or develop python extensions for KNIME Analytics Platform in the KNIME documentation:
- Clone this repository or use it as a template (click on the green "Use this template" button):
- Edit
knime.yml- provide your metadata, license, ... - Modify the
src/extension.pyfile or add further files to implement your own logic. Note that every py file equivalent to one node needs to be imported in the init.py file. - Install the python environment:
This will install the Python environment as defined in the
pixi install
pixi.tomlfile. If you leave this file unchanged, the Python environment that is installed will have the needed KNIME packages installed per default (knime-python-versions). - (Optional) Add python packages to the environment with the following command, or by manually editing the
pixi.tomlfile:Note that you have to run thepixi add <package_name>
pixi installcommand again after manually editing thepixi.tomlfile. - Install the extension in debug mode in your KNIME Analytics Platform by running the following command:
Previously this step required modifying the
pixi run register-debug-in-knimeconfig.ymlandknime.inifiles manually. This improvement will allow you to select your KNIME Analytics Platform installation and append the-Dknime.python.extension.debug_knime_yaml_list=<path/to/your/knime.yml>argument automatically to the accordingknime.inifile. You can now test your extension in the KNIME Analytics Platform (e.g. demo workflow). - Bundle your extension:
or if you want the extension's local update site in a specific location (default is
pixi run build
./local_update_site):pixi run build dest=<path_to_your_update_site>
- Install the update site in KNIME via
and enter the path to your update site (by default
File > Install KNIME Extensions... > Available Software Sites > Add...
./local_update_site). After that, you can install your extension. - To publish on KNIME Hub, follow the KNIME Hub documentation.
For detailed instructions on how to create a KNIME Python extension, please refer to the KNIME Python Extension documentation.
Unit tests live in tests/ and run with pytest:
pixi run testThe coverage task additionally produces a JUnit report (pytest-results.xml) and a coverage report (coverage.xml):
pixi run coverageThe KNIME Jenkins build auto-detects this setup (a pixi test environment providing a coverage task) and runs it on every build, publishing the test results to Jenkins and the coverage to SonarQube. Failing tests mark the build UNSTABLE. The output file names and the test/coverage names are the contract with the build — keep them if you want CI to pick your tests up. Adjust the --cov=... targets in pixi.toml when your sources live outside src/, and keep .coveragerc (it makes coverage paths machine-independent).
Note that after adding or changing test dependencies you must run pixi lock and commit the updated pixi.lock — the CI runs with --frozen --locked.
Format the sources with Ruff:
pixi run formatRuff and debugpy live in the dev feature, not in the default environment. The default environment is what pixi run build bundles into the extension, so keep development tooling out of it and add such packages with pixi add --feature dev <package>.
