Skip to content

Nodes

class knime.extension.PythonNode

Extend this class to provide a pure Python based node extension to KNIME Analytics Platform.

Users can either use the decorators @knext.input_table, @knext.input_binary, @knext.output_table, @knext.output_binary, and @knext.output_view, or populate the input_ports, output_ports, and output_view attributes.

Use the Python logging facilities and its .warning and .error methods to write warnings and errors to the KNIME console. .info and .debug will only show up in the KNIME console if the log level in KNIME is configured to show these.

Examples
python
>>> import logging
... import knime.extension as knext
...
... LOGGER = logging.getLogger(__name__)
...
... category = knext.category("/community", "mycategory", "My Category", "My category described", icon="icons/category.png")
...
... @knext.node(name="Pure Python Node", node_type=knext.NodeType.LEARNER, icon_path="icons/icon.png", category=category)
... @knext.input_table(name="Input Data", description="We read data from here")
... @knext.output_table(name="Output Data", description="Whatever the node has produced")
... class TemplateNode(knext.PythonNode):
...     # A Python node has a description.
...
...     def configure(self, configure_context, table_schema):
...         LOGGER.info(f"Configuring node")
...         return table_schema
...
...     def execute(self, exec_context, table):
...         return table
method configure(config_context: ConfigurationContext, *inputs)

Configure this Python node.

Parameters
  • config_context : ConfigurationContext — The ConfigurationContext providing KNIME utilities during execution
  • *inputs — Each input table spec or binary port spec will be added as parameter, in the same order that the ports were defined.
Returns

Union[Spec, List[Spec], Tuple[Spec, ...], Column] — Either a single spec, or a tuple or list of specs. The number of specs must match the number of defined output ports, and they must be returned in this order. Alternatively, instead of a spec, a knext.Column can be returned (if the spec shall only consist of one column). Return knext.InactivePort for an output slot to mark that port inactive.

Raises
  • InvalidParametersError — If the current input parameters do not satisfy this node's requirements.
method execute(exec_context: ExecutionContext, *inputs)

Execute this Python node.

Parameters
  • exec_context : ExecutionContext — The ExecutionContext providing KNIME utilities during execution.
  • *inputs : tuple — Each input table or binary port object will be added as a parameter, in the same order that the ports were defined. Tables will be provided as a kn.Table, while binary data will be a plain Python bytes object.
Returns

object or tuple/list of objects — Either a single output object (table or binary), or a tuple or list of objects. The number of output objects must match the number of defined output ports, and they must be returned in this order. Tables must be provided as a kn.Table or kn.BatchOutputTable, while binary data should be returned as plain Python bytes object. Return knext.InactivePort for an output slot to mark that port inactive.

attribute input_ports : List[Port]
attribute output_ports : List[Port]
attribute output_view : ViewDeclaration

function knime.extension.category(path: str, level_id: str, name: str, description: str, icon: str, after: str = '', locked: bool = True)

Register a new node category.

A node category must be created only once. Use the string that represents the absolute category path to add nodes to an existing category.

Examples
python
>>> node_category = knext.category(
...     "/testing", "python-nodes", "Python Nodes", "Python testing nodes", "icon.png"
... )
...
... @knext.node(
...     name="Simple Python Node",
...     node_type=knext.NodeType.MANIPULATOR,
...     icon_path="icon.png",
...     category=node_category
... )
... class SimpleNode(knext.PythonNode):
...     pass
Parameters
  • path : str — The absolute path that leads to this category, e.g., "/io/read". The segments are the category level-IDs, separated by a slash ("/"). Categories that contain community nodes should be placed in the "/community" category.
  • level_id : str — The identifier of the level which is used as a path-segment and must be unique at the level specified by "path".
  • name : str — The name of this category, e.g., "File readers".
  • description : str — A short description of the category.
  • icon : str — File path to a 16x16 pixel PNG icon for this category. The path must be relative to the root of the extension.
  • after : str — Specifies the level-id of the category after which this category should be sorted. Defaults to "".
  • locked : bool — Set this to False to allow extensions from other vendors to add sub-categories or nodes to this category. Defaults to True.
Returns

str — The full path of the category, which can be used to create nodes inside this category.

class knime.extension.NodeType

Defines the different node types that are available for Python based nodes.

attribute LEARNER = 'Learner'

A node learning a model that is typically consumed by a PREDICTOR.

attribute MANIPULATOR = 'Manipulator'

A node that manipulates data.

attribute OTHER = 'Other'

A node that doesn't fit one of the other node types.

attribute PREDICTOR = 'Predictor'

A node that predicts something typically using a model provided by a LEARNER.

attribute SINK = 'Sink'

A node consuming data.

attribute SOURCE = 'Source'

A node producing data.

attribute VISUALIZER = 'Visualizer'

A node that visualizes data.

class knime.extension.ConfigurationContext

The ConfigurationContext provides utilities to communicate with KNIME during a node's configure() method.

method __init__(java_ctx, flow_variables, input_ports = None, output_ports = None) → None
property flow_variables → Dict[str, Any]

The flow variables coming in from KNIME as a dictionary with string keys.

Notes

The dictionary can be edited and supports flow variables of the following types:

  • bool
  • list[bool]
  • float
  • list[float]
  • int
  • list[int]
  • str
  • list[str]
method get_connected_input_port_numbers() → List[int]

Gets the number of connected input ports for each port.

This method can be used to know how many input ports are connected to the node for each port.

Returns

list of int — A list of the number of connected input ports for each port type.

method get_connected_output_port_numbers() → List[int]

Gets the number of connected output ports for each port.

This method can be used to know how many output ports are connected to the node for each port. This is relevant when using PortGroups to determine which ports have to be populated with data.

Examples
python
>>> @node(name="Example Node with Group Ports")
... @input_table(name="Input Data", description="The data to process in my node")
... @output_table_group(name="Output Data", description="Multiple outputs from my node")
... class ExampleNode(PythonNode):
...     # ...
...     def execute(self, exec_context, table)->List[knext.Schema]:
...         output_table = table
...         connected_output_ports  = exec_context.get_connected_output_port_numbers()
...         # When 2 output ports are connected, this will return [2].
...         output_tables = [output_table] * connected_output_ports[0]
...         return output_tables # Thus, one list with two tables has to be returned.
Returns

list of int — A list of the number of connected output ports for each port type.

method get_credential_names()

Returns the identifier (flow variable name) for each credential.

Returns

list — A list of credential names.

method get_credentials(identifier: str) → Credential

Returns the credentials dataclass for the given identifier.

Parameters
  • identifier : str — The identifier of the credentials to retrieve.
Returns

Credential — A dataclass containing the credentials.

method set_warning(message: str) → None

Sets a warning on the node.

Parameters
  • message : str — The warning message to display on the node.

class knime.extension.ExecutionContext

The ExecutionContext provides utilities to communicate with KNIME during a node's execute() method.

method __init__(java_ctx, flow_variables, input_ports = None, output_ports = None) → None
property flow_variables → Dict[str, Any]

The flow variables coming in from KNIME as a dictionary with string keys.

Notes

The dictionary can be edited and supports flow variables of the following types:

  • bool
  • list[bool]
  • float
  • list[float]
  • int
  • list[int]
  • str
  • list[str]
method get_connected_input_port_numbers() → List[int]

Gets the number of connected input ports for each port.

This method can be used to know how many input ports are connected to the node for each port.

Returns

list of int — A list of the number of connected input ports for each port type.

method get_connected_output_port_numbers() → List[int]

Gets the number of connected output ports for each port.

This method can be used to know how many output ports are connected to the node for each port. This is relevant when using PortGroups to determine which ports have to be populated with data.

Examples
python
>>> @node(name="Example Node with Group Ports")
... @input_table(name="Input Data", description="The data to process in my node")
... @output_table_group(name="Output Data", description="Multiple outputs from my node")
... class ExampleNode(PythonNode):
...     # ...
...     def execute(self, exec_context, table)->List[knext.Schema]:
...         output_table = table
...         connected_output_ports  = exec_context.get_connected_output_port_numbers()
...         # When 2 output ports are connected, this will return [2].
...         output_tables = [output_table] * connected_output_ports[0]
...         return output_tables # Thus, one list with two tables has to be returned.
Returns

list of int — A list of the number of connected output ports for each port type.

method get_credential_names()

Returns the identifier (flow variable name) for each credential.

Returns

list — A list of credential names.

method get_credentials(identifier: str) → Credential

Returns the credentials dataclass for the given identifier.

Parameters
  • identifier : str — The identifier of the credentials to retrieve.
Returns

Credential — A dataclass containing the credentials.

method get_knime_home_dir() → str

Returns the local absolute path to the directory in which KNIME stores its configuration as well as log files.

Returns

str — The local absolute path to the KNIME directory.

method get_workflow_data_area_dir() → str

Returns the local absolute path to the current workflow's data area folder. This folder is meant to be part of the workflow, so its contents are included whenever the workflow is shared.

method get_workflow_temp_dir() → str

Returns the local absolute path where temporary files for this workflow should be stored. Files created in this folder are not automatically deleted by KNIME.

By default, this folder is located in the operating system's temporary folder. In that case, the contents will be cleaned by the OS.

method is_canceled() → bool

Returns true if this node's execution has been canceled from KNIME. Nodes can check for this property and return early if the execution does not need to finish. Raising a RuntimeError in that case is encouraged.

method set_progress(progress: float, message: str = None)

Set the progress of the execution.

Note that the progress that can be set here is 80% of the total progress of a node execution. The first and last 10% are reserved for data transfer and will be set by the framework.

Parameters
  • progress : float — A floating point number between 0.0 and 1.0.
  • message : str — An optional message to display in KNIME with the progress.
method set_warning(message: str) → None

Sets a warning on the node.

Parameters
  • message : str — The warning message to display on the node.

class knime.extension.DialogCreationContext

The DialogCreationContext provides utilities to communicate with KNIME during the dialog creation phase. It enables access to the flow variables, the specs of the input tables and the credentials. These can be used to create the dialog elements, by passing the respective method as lambda function to the constructor of the string parameter class. The lambdas will receive the dialog creation context as parameter which should be passed as first parameter to the fully qualified method calls of DialogCreationContext as below:

Examples
python
>>> class ExampleNode:
...     # This dialog element displays a dropdown with all available credentials
...     string_param = knext.StringParameter(label="Credential parameter", description="Choices is a callable",
...                                 choices=lambda a: knext.DialogCreationContext.get_credential_names(a))
method __init__(java_ctx, flow_variables, specs_to_python_converter) → None

Initialize the object.

Parameters
  • java_ctx : JavaContext — The JavaContext object.
  • flow_variables : list — The list of flow variables.
  • specs_to_python_converter : function — The function to convert Java specifications to Python.
property flow_variables → Dict[str, Any]

The flow variables coming in from KNIME as a dictionary with string keys.

Notes

The dictionary can be edited and supports flow variables of the following types:

  • bool
  • list[bool]
  • float
  • list[float]
  • int
  • list[int]
  • str
  • list[str]
method get_credential_names()

Returns the identifier (flow variable name) for each credential.

Returns

list — A list of credential names.

method get_credentials(identifier: str) → Credential

Returns the credentials dataclass for the given identifier.

Parameters
  • identifier : str — The identifier of the credentials to retrieve.
Returns

Credential — A dataclass containing the credentials.

method get_flow_variables()

Returns the flow variables coming in from KNIME as a dictionary with string keys. The dictionary cannot be edited.

Returns

dict — The flow variables dictionary with string keys.

Notes

The supported flow variable types are:

  • bool
  • list(bool)
  • float
  • list(float)
  • int
  • list(int)
  • str
  • list(str)
method get_input_specs() → List[PortObjectSpec]

Returns the specs for all input ports of the node.

Returns

List — A list of specs for all input ports.

Decorators

These decorators can be used to easily configure your Python node.

function knime.extension.node(name: str, node_type: NodeType, icon_path: str, category: str, after: str = None, keywords: Optional[List[str]] = None, id: str = None, is_deprecated: bool = False, is_hidden: bool = False) → Callable

Use this decorator to annotate a PythonNode class or function that creates a PythonNode instance that should correspond to a node in KNIME.

Parameters
  • name : str — The name of the node
  • node_type : NodeType — Type can be Source, Sink, Learner, Predictor, Manipulator, Visualizer or Other.
  • icon_path : str — String to icon if no path is given it has no icon.
  • category : str — Category to which the node will belongs to. The node will appear under this category. E.g. community.
  • after : str — If given the node will be listed after the specified node.
  • keywords : Optional[List[str]] — Keywords describing your node which will help finding the node during search.
  • id : str — Id of your node.
  • is_deprecated : bool — Default is false.
  • is_hidden : bool — Default is false. If true your node will not shown during search and not be listed in it's category.
Returns

Callable — Returns a function which will decorate your node implementation with the set parameters.

Port Decorators

Port decorators allow you to define input and output ports for your nodes. Each port is of a specific type, such as Table or Binary.

function knime.extension.input_table(name: str, description: str, optional: Optional[bool] = False)

Use this decorator to define an input port of type "Table" of a node.

Parameters
  • name : str — The name of the input port.
  • description : str — A description of the input port.
  • optional : Optional[bool] — Whether the port is optional i.e. can be added by the user

function knime.extension.input_binary(name: str, description: str, id: str, optional: Optional[bool] = False)

Use this decorator to define a bytes-serialized port object input of a node.

Parameters
  • name : str — The name of the input port.
  • description : str — A description of the input port.
  • id : str — A unique ID identifying the type of the Port. Only Ports with equal ID can be connected in KNIME.
  • optional : Optional[bool] — Whether the port is optional i.e. can be left unconnected by the user.

function knime.extension.input_port(name: str, description: str, port_type: PortType, optional: Optional[bool] = False)

Use this decorator to add an input port of the provided type to a node.

Parameters
  • name : str — The name of the input port.
  • description : str — A description of the input port.
  • port_type : PortType — The type of the input port.
  • optional : Optional[bool] — Whether the port is optional i.e. can be added by the user

function knime.extension.output_table(name: str, description: str)

Use this decorator to define an output port of type "Table" of a node.

Parameters
  • name : str — The name of the port.
  • description : str — Description of what the port is used for.

function knime.extension.output_image(name: str, description: str)

Use this decorator to define an output port of the type "Image" of a node.

The configure method must return specs of the type ImagePortObjectSpec. The execute method must return a bytes object containing the image data. Note that the image data must be valid for the format defined in configure.

Parameters
  • name : str — The name of the image output port
  • description : str — Description of the image output port
Examples
python
>>> @knext.node(...)
... @knext.output_image(
...     name="PNG Output Image",
...     description="An example PNG output image")
... @knext.output_image(
...     name="SVG Output Image",
...     description="An example SVG output image")
... class ImageNode:
...     def configure(self, config_context):
...         return (
...             knext.ImagePortObjectSpec(knext.ImageFormat.PNG),
...             knext.ImagePortObjectSpec(knext.ImageFormat.SVG),
...         )
...
...     def execute(self, exec_context):
...         # create a plot ...
...         buffer_png = io.BytesIO()
...         plt.savefig(buffer_png, format="png")
...
...         buffer_svg = io.BytesIO()
...         plt.savefig(buffer_svg, format="svg")
...
...         return (
...             buffer_png.getvalue(),
...             buffer_svg.getvalue(),
...         )

function knime.extension.output_binary(name: str, description: str, id: str)

Use this decorator to define a bytes-serialized port object output of a node.

Parameters
  • name : str — The name of the port.
  • description : str — The description of the port.
  • id : str — A unique ID identifying the type of the Port. Only Ports with equal ID can be connected in KNIME.

function knime.extension.output_port(name: str, description: str, port_type: PortType)

Use this decorator to add an output port of the provided type to a node.

Parameters
  • name : str — The name of the port.
  • description : str — Description of what the port is used for.
  • port_type : type — The type of the port to add.

function knime.extension.output_view(name: str, description: str, static_resources: Optional[str] = None, index_html_path: Optional[str] = None)

Use this decorator to specify that this node produces a view.

Parameters
  • name : str — The name of the view.
  • description : str — Description of the view.
  • static_resources : str — Path (relative to the extension root) to a folder of static resources (e.g., JS, CSS, images, HTML files) that will be made available to the view. All text-based resources must be UTF-8 encoded.
  • index_html_path : str — Path (relative to the static_resources folder) to the HTML file that should be used as the entry point for the view (e.g., "index.html"). If specified, the view will be rendered using this static HTML file and its assets from static_resources. If not specified, the node's execute method must return a view object.

Notes

  • Use static_resources to provide all static files needed for your view (including HTML, JS, CSS, images, etc.).
  • Use index_html_path to specify which HTML file inside static_resources should be used as the entry point for a static view.
  • If index_html_path is not provided, the node is expected to return a view object from its execute method.
Examples

Dynamic view (no static resources, returns a view object from execute):

python
>>> @knext.output_view(
...     name="Dynamic View",
...     description="Shows a dynamic view generated in Python."
... )

Static HTML/JS view with resources:

python
>>> @knext.output_view(
...     name="Custom Static View",
...     description="Shows a static HTML/JS visualization.",
...     static_resources="my_view_assets",
...     index_html_path="index.html"
... )

Port Group Decorators

Group decorators allow you to define input and output port groups. A port group allows dynamic addition and removal of ports in KNIME.

function knime.extension.input_table_group(name: str, description: str)

Use this decorator to define an input port group of type "Table" of a node.

Parameters
  • name : str — The name of the input port group. Must be unique for all input port groups.
  • description : str — A description of the input port group.
Examples
python
>>> @knext.node(
...     name="Example Node with Multiple Input Table Groups",
...     node_type=knext.NodeType.MANIPULATOR,
...     icon_path="icon.png",
...     category="community/example"
... )
... @knext.input_table_group(
...     name="First Input Tables",
...     description="The first group of input tables for processing"
... )
... @knext.input_table_group(
...     name="Second Input Tables",
...     description="The second group of input tables for processing"
... )
... @knext.output_table_group(
...     name="Output Tables",
...     description="Combined results of the input tables"
... )
... class ConcatenateNode(knext.PythonNode):
...     def configure(self, config_context, first_table_specs: List[knext.Schema], second_table_specs: List[knext.Schema]) -> Iterable[List[knext.Schema]]:
...         return first_table_specs + second_table_specs
...
...     def execute(self, exec_context, first_tables: List[knext.Table], second_tables: List[knext.Table]) -> Iterable[List[knext.Table]]:
...         return first_tables + second_tables

function knime.extension.input_binary_group(name: str, description: str, id: Optional[str] = None)

Use this decorator to define an input port group of type "Binary" for a node.

Parameters
  • name : str — The name of the input port group. Must be unique for all input port groups.
  • description : str — A description of the input port group.
  • id : Optional[str] — A unique ID identifying the type of the PortGroup. Only PortGroups with equal ID can be connected in KNIME.

function knime.extension.output_table_group(name: str, description: str)

Use this decorator to define an output port group of type "Table" of a node.

Parameters
  • name : str — The name of the output port. Must be unique for all output port groups.
  • description : str — A description of the output port.

function knime.extension.output_image_group(name: str, description: str)

Use this decorator to define an output port group of the type "Image" of a node.

The configure method must return specs of the type ImagePortObjectSpec. The execute method must return a bytes object containing the image data. Note that the image data must be valid for the format defined in configure.

Parameters
  • name : str — The name of the image output port. Must be unique for all output port groups.
  • description : str — Description of the image output port
Examples
python
>>> @knext.node(...)
... @knext.output_image_group(
...     name="PNG Output Image Group",
...     description="An example PNG output image")
... @knext.output_image_group(
...     name="SVG Output Image Group",
...     description="An example SVG output image")
... class ImageNode:
...     def configure(self, config_context):
...         # if 2 ports are connected per group, we will have 2 PNG and 2 SVG outputs
...         port_numbers = config_context.get_connected_output_port_numbers()
...         return (
...             [knext.ImagePortObjectSpec(knext.ImageFormat.PNG]*port_numbers[0],
...             [knext.ImagePortObjectSpec(knext.ImageFormat.SVG)]*port_numbers[1],
...         )
...
...     def execute(self, exec_context):
...         # create a plot ...
...         buffer_png = io.BytesIO()
...         plt.savefig(buffer_png, format="png")
...
...         buffer_svg = io.BytesIO()
...         plt.savefig(buffer_svg, format="svg")
...
...         return (
...             [buffer_png.getvalue()]*2,
...             [buffer_svg.getvalue()]*2,
...         )

function knime.extension.output_binary_group(name: str, description: str, id: Optional[str] = None)

Use this decorator to define an output port group of type "Binary" for a node.

Parameters
  • name : str — The name of the output port group. Must be unique for all output port groups.
  • description : str — A description of the output port group.
  • id : Optional[str] — A unique ID identifying the type of the PortGroup. Only PortGroups with equal ID can be connected in KNIME.

Parameters

To add parameterization to your nodes, define and customize the configuration dialog. Access each parameter in the node's execution via self.param_name.

class knime.extension.IntParameter

Parameter class for primitive integer types.

method __init__(label: Optional[str] = None, description: Optional[str] = None, default_value: Union[int, DefaultValueProvider[int]] = 0, validator: Optional[Callable[[int], None]] = None, min_value: Optional[int] = None, max_value: Optional[int] = None, since_version: Optional[Union[Version, str]] = None, is_advanced: bool = False)
method check_range(value)
method check_type(value)
attribute max_value
attribute min_value
method rule(condition: Condition, effect: Effect)

Add a rule that conditionally sets whether this parameter is visible or enabled in the dialog. This can be useful if this parameter should only be accessible if another parameter has a certain value.

Note

Rules can only depend on parameters on the same level, not in a child or parent parameter group.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     string_param = knext.StringParameter(
...         "String Param Title",
...         "String Param Title Description",
...         "default value"
...     )
...
...     # this parameter gets disabled if string_param is "foo" or "bar"
...     int_param = knext.IntParameter(
...         "Int Param Title",
...         "Int Param Description",
...     ).rule(knext.OneOf(string_param, ["foo", "bar"]), knext.Effect.DISABLE)
method validator(func)

To be used as a decorator for setting a validator function for a parameter. Note that 'func' will be encapsulated in '_validator' and will not be available in the namespace of the class.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     num_repetitions = knext.IntParameter(
...         label="Number of repetitions",
...         description="How often to repeat an action",
...         default_value=42
...     )
...     @num_repetitions.validator
...     def validate_reps(value):
...         if value > 100:
...             raise ValueError("Too many repetitions!")
...
...     def configure(args):
...         pass
...
...     def execute(args):
...         pass

class knime.extension.DoubleParameter

Parameter class for primitive float types.

method __init__(label: Optional[str] = None, description: Optional[str] = None, default_value: Union[float, DefaultValueProvider[float]] = 0.0, validator: Optional[Callable[[float], None]] = None, min_value: Optional[float] = None, max_value: Optional[float] = None, since_version: Optional[Union[str, Version]] = None, is_advanced: bool = False)
method check_range(value)
method check_type(value)
attribute max_value
attribute min_value
method rule(condition: Condition, effect: Effect)

Add a rule that conditionally sets whether this parameter is visible or enabled in the dialog. This can be useful if this parameter should only be accessible if another parameter has a certain value.

Note

Rules can only depend on parameters on the same level, not in a child or parent parameter group.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     string_param = knext.StringParameter(
...         "String Param Title",
...         "String Param Title Description",
...         "default value"
...     )
...
...     # this parameter gets disabled if string_param is "foo" or "bar"
...     int_param = knext.IntParameter(
...         "Int Param Title",
...         "Int Param Description",
...     ).rule(knext.OneOf(string_param, ["foo", "bar"]), knext.Effect.DISABLE)
method validator(func)

To be used as a decorator for setting a validator function for a parameter. Note that 'func' will be encapsulated in '_validator' and will not be available in the namespace of the class.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     num_repetitions = knext.IntParameter(
...         label="Number of repetitions",
...         description="How often to repeat an action",
...         default_value=42
...     )
...     @num_repetitions.validator
...     def validate_reps(value):
...         if value > 100:
...             raise ValueError("Too many repetitions!")
...
...     def configure(args):
...         pass
...
...     def execute(args):
...         pass

class knime.extension.BoolParameter

Parameter class for primitive boolean types.

method __init__(label: Optional[str] = None, description: Optional[str] = None, default_value: Union[bool, DefaultValueProvider[bool]] = False, validator: Optional[Callable[[bool], None]] = None, since_version: Optional[Union[Version, str]] = None, is_advanced: bool = False)
method rule(condition: Condition, effect: Effect)

Add a rule that conditionally sets whether this parameter is visible or enabled in the dialog. This can be useful if this parameter should only be accessible if another parameter has a certain value.

Note

Rules can only depend on parameters on the same level, not in a child or parent parameter group.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     string_param = knext.StringParameter(
...         "String Param Title",
...         "String Param Title Description",
...         "default value"
...     )
...
...     # this parameter gets disabled if string_param is "foo" or "bar"
...     int_param = knext.IntParameter(
...         "Int Param Title",
...         "Int Param Description",
...     ).rule(knext.OneOf(string_param, ["foo", "bar"]), knext.Effect.DISABLE)
method validator(func)

To be used as a decorator for setting a validator function for a parameter. Note that 'func' will be encapsulated in '_validator' and will not be available in the namespace of the class.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     num_repetitions = knext.IntParameter(
...         label="Number of repetitions",
...         description="How often to repeat an action",
...         default_value=42
...     )
...     @num_repetitions.validator
...     def validate_reps(value):
...         if value > 100:
...             raise ValueError("Too many repetitions!")
...
...     def configure(args):
...         pass
...
...     def execute(args):
...         pass

class knime.extension.StringParameter

Parameter class for primitive string types.

Dynamic Choices

The optional choices callable may return either a list/tuple of plain strings or StringParameter.Choice objects. Plain strings are interpreted as choices with identical id and label and an empty description. Choice objects allow specifying a user-facing label and an optional description while persisting only the stable id. Descriptions (if any) are aggregated into the parameter description under an "Available options" section. The section is included only if at least one dynamic choice supplies a non-empty description.

Examples
python
>>> def basic(ctx):
...     return ["A", "B"]
...
>>> def rich(ctx):
...     return [
...         StringParameter.Choice("A", "Option A", "Description for A"),
...         StringParameter.Choice("B", "Option B"),  # no description
...     ]
...
>>> param = knext.StringParameter(
...     label="Example",
...     description="Pick an option.",
...     choices=rich, # alternatively: choices=basic
...     default_value="A",
... )
method __init__(label: Optional[str] = None, description: Optional[str] = None, default_value: Union[str, DefaultValueProvider[str]] = '', enum: Optional[List[str]] = None, validator: Optional[Callable[[str], None]] = None, since_version: Optional[Union[Version, str]] = None, is_advanced: bool = False, choices: Optional[Callable] = None)
class dataclass knime.extension.StringParameter.Choice
method __init__(id: str, label: str, description: str = '') → None
attribute description : str
attribute id : str
attribute label : str
method rule(condition: Condition, effect: Effect)

Add a rule that conditionally sets whether this parameter is visible or enabled in the dialog. This can be useful if this parameter should only be accessible if another parameter has a certain value.

Note

Rules can only depend on parameters on the same level, not in a child or parent parameter group.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     string_param = knext.StringParameter(
...         "String Param Title",
...         "String Param Title Description",
...         "default value"
...     )
...
...     # this parameter gets disabled if string_param is "foo" or "bar"
...     int_param = knext.IntParameter(
...         "Int Param Title",
...         "Int Param Description",
...     ).rule(knext.OneOf(string_param, ["foo", "bar"]), knext.Effect.DISABLE)
method validator(func)

To be used as a decorator for setting a validator function for a parameter. Note that 'func' will be encapsulated in '_validator' and will not be available in the namespace of the class.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     num_repetitions = knext.IntParameter(
...         label="Number of repetitions",
...         description="How often to repeat an action",
...         default_value=42
...     )
...     @num_repetitions.validator
...     def validate_reps(value):
...         if value > 100:
...             raise ValueError("Too many repetitions!")
...
...     def configure(args):
...         pass
...
...     def execute(args):
...         pass

class knime.extension.ColumnParameter

Parameter class for single columns.

method __init__(label: Optional[str] = None, description: Optional[str] = None, port_index: int = 0, column_filter: Callable[[ks.Column], bool] = None, include_row_key: bool = False, include_none_column: bool = False, since_version: Optional[str] = None, is_advanced: bool = False, schema_provider = None, default_value: Optional[Union[str, DefaultValueProvider[str]]] = None)
Parameters
  • label : str — Label of the parameter in the dialog
  • description : str — Description of the parameter in the node description and dialog
  • port_index : int — The input port to select columns. Ignored if a schema_provider is specified.
  • column_filter : function — A function for prefiltering columns
  • include_row_key : bool — Whether to include the row keys as selectable column
  • include_none_column : bool — Whether to allow to select no column
  • since_version : str — The version at which this parameter was introduced. Can be omitted if the parameter is part of the first version of the node.
  • schema_provider — A function that takes a DialogCreationContext and extracts a Schema from it.
  • is_advanced : bool — Whether the parameter is shown in the advanced settings of the dialog.
  • default_value : str — The column selected by default, or a callable deriving it from the dialog creation context.
attribute NONE = '<none>'
method rule(condition: Condition, effect: Effect)

Add a rule that conditionally sets whether this parameter is visible or enabled in the dialog. This can be useful if this parameter should only be accessible if another parameter has a certain value.

Note

Rules can only depend on parameters on the same level, not in a child or parent parameter group.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     string_param = knext.StringParameter(
...         "String Param Title",
...         "String Param Title Description",
...         "default value"
...     )
...
...     # this parameter gets disabled if string_param is "foo" or "bar"
...     int_param = knext.IntParameter(
...         "Int Param Title",
...         "Int Param Description",
...     ).rule(knext.OneOf(string_param, ["foo", "bar"]), knext.Effect.DISABLE)
method validator(func)

To be used as a decorator for setting a validator function for a parameter. Note that 'func' will be encapsulated in '_validator' and will not be available in the namespace of the class.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     num_repetitions = knext.IntParameter(
...         label="Number of repetitions",
...         description="How often to repeat an action",
...         default_value=42
...     )
...     @num_repetitions.validator
...     def validate_reps(value):
...         if value > 100:
...             raise ValueError("Too many repetitions!")
...
...     def configure(args):
...         pass
...
...     def execute(args):
...         pass

class knime.extension.MultiColumnParameter

Parameter class for multiple columns.

method __init__(label: Optional[str] = None, description: Optional[str] = None, port_index: Optional[int] = 0, column_filter: Optional[Callable[[ks.Column], bool]] = None, since_version: Optional[Union[str, Version]] = None, is_advanced: bool = False)
Parameters
  • label : str — A string label for the object (default is None).
  • description : str — A string description of the object (default is None).
  • port_index : int — An integer representing the port index (default is 0).
  • column_filter : callable — A function that takes a ks.Column object and returns a boolean value (default is None).
  • since_version : Union[str, Version] — A string or Version object representing the version since when the object is available (default is None).
  • is_advanced : bool — A boolean indicating if the object is advanced (default is False).
method rule(condition: Condition, effect: Effect)

Add a rule that conditionally sets whether this parameter is visible or enabled in the dialog. This can be useful if this parameter should only be accessible if another parameter has a certain value.

Note

Rules can only depend on parameters on the same level, not in a child or parent parameter group.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     string_param = knext.StringParameter(
...         "String Param Title",
...         "String Param Title Description",
...         "default value"
...     )
...
...     # this parameter gets disabled if string_param is "foo" or "bar"
...     int_param = knext.IntParameter(
...         "Int Param Title",
...         "Int Param Description",
...     ).rule(knext.OneOf(string_param, ["foo", "bar"]), knext.Effect.DISABLE)
method validator(func)

To be used as a decorator for setting a validator function for a parameter. Note that 'func' will be encapsulated in '_validator' and will not be available in the namespace of the class.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     num_repetitions = knext.IntParameter(
...         label="Number of repetitions",
...         description="How often to repeat an action",
...         default_value=42
...     )
...     @num_repetitions.validator
...     def validate_reps(value):
...         if value > 100:
...             raise ValueError("Too many repetitions!")
...
...     def configure(args):
...         pass
...
...     def execute(args):
...         pass

class knime.extension.ColumnFilterParameter

Parameter class that supports full column filtering for columns.

method __init__(label: Optional[str] = None, description: Optional[str] = None, port_index: Optional[int] = 0, default_value: Optional[Union[ColumnFilterConfig, DefaultValueProvider[ColumnFilterConfig]]] = None, column_filter: Callable[[ks.Column], bool] = None, since_version: Optional[Union[str, Version]] = None, is_advanced: bool = False, schema_provider = None)
method rule(condition: Condition, effect: Effect)

Add a rule that conditionally sets whether this parameter is visible or enabled in the dialog. This can be useful if this parameter should only be accessible if another parameter has a certain value.

Note

Rules can only depend on parameters on the same level, not in a child or parent parameter group.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     string_param = knext.StringParameter(
...         "String Param Title",
...         "String Param Title Description",
...         "default value"
...     )
...
...     # this parameter gets disabled if string_param is "foo" or "bar"
...     int_param = knext.IntParameter(
...         "Int Param Title",
...         "Int Param Description",
...     ).rule(knext.OneOf(string_param, ["foo", "bar"]), knext.Effect.DISABLE)
method validator(func)

To be used as a decorator for setting a validator function for a parameter. Note that 'func' will be encapsulated in '_validator' and will not be available in the namespace of the class.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     num_repetitions = knext.IntParameter(
...         label="Number of repetitions",
...         description="How often to repeat an action",
...         default_value=42
...     )
...     @num_repetitions.validator
...     def validate_reps(value):
...         if value > 100:
...             raise ValueError("Too many repetitions!")
...
...     def configure(args):
...         pass
...
...     def execute(args):
...         pass

class knime.extension.ColumnFilterConfig

The value of a ColumnFilterParameter is a ColumnFilterConfig instance with a mode as well as configuration for the different modes.

Use the apply method to filter schemas and tables according to this filter config

Examples
python
>>> @knext.node(
...     name="Python Column Filter",
...     node_type=knext.NodeType.MANIPULATOR,
...     icon_path=...,
...     category=...,
... )
... @knext.input_table("Input Table", "Input table.")
... @knext.output_table("Output Table", "Output table.")
... class ColumnFilterNode:
...     column_filter = knext.ColumnFilterParameter("Column Filter", "Column Filter")
...
...     def configure(self, config_context, input_schema: knext.Schema):
...         return self.column_filter.apply(input_schema)
...
...     def execute(self, exec_context, input_table):
...         return self.column_filter.apply(input_table)
method __init__(mode = ColumnFilterMode.MANUAL, pattern_filter: PatternFilterConfig = None, type_filter: TypeFilterConfig = None, manual_filter: ManualFilterConfig = None, included_column_names: List[str] = None, pre_filter: Callable[[ks.Column], bool] = None)

Construct a ColumnFilterConfig with given mode, pattern_filter, type_filter, and manual_filter.

If included_column_names are provided, manual_filter and mode will be ignored and will be configured such that only the explicitly included_column_names (and unknown columns) are selected.

method apply(columnar: ks._Columnar) → ks._Columnar

Filter a table schema or a table according to this column filter configuration.

attribute manual_filter
attribute mode
attribute pattern_filter
attribute type_filter

class knime.extension.EnumParameter

Parameter class for multiple-choice parameter types. Replicates and extends the enum functionality previously implemented as part of StringParameter.

A subclass of EnumParameterOptions should be provided as the enum parameter, which should contain class attributes of the form OPTION_NAME = (OPTION_LABEL, OPTION_DESCRIPTION). The corresponding option attributes can be accessed via MyOptions.OPTION_NAME.name, .label, and .description respectively.

The .name attribute of each option is used as the selection constant, e.g. MyOptions.OPTION_NAME.name == "OPTION_NAME".

Examples
python
>>> class CoffeeOptions(EnumParameterOptions):
...     CLASSIC = ("Classic", "The classic chocolatey taste, with notes of bitterness and wood.")
...     FRUITY = ("Fruity", "A fruity taste, with notes of berries and citrus.")
...     WATERY = ("Watery", "A watery taste, with notes of water and wetness.")
...
... coffee_selection_param = knext.EnumParameter(
...     label="Coffee Selection",
...     description="Select the type of coffee you like to drink.",
...     default_value=CoffeeOptions.CLASSIC.name,
...     enum=CoffeeOptions,
... )

Dynamic Filtering

The optional hidden_choices callable allows filtering which enum members are hidden in the dialog and node description based on the runtime context. This is useful for hiding options that are not applicable given the current input data.

The callable receives a DialogCreationContext (or None if the node is not connected or during node description generation at startup) and must return a list of enum members to hide. If None or an empty list is returned, all options are shown. If the callable returns only invalid members or all members, a warning is logged.

Important: Validation accepts any enum member regardless of filtering. This ensures that saved workflows remain valid even when the context changes and different options are filtered.

The DialogCreationContext parameter can be None in two scenarios:

  • During node description generation at KNIME startup
  • When the node has no input connections

Your callable should handle None gracefully. By returning different options based on whether the context is None, you can control what appears in the node description versus the dialog. For example, returning items to hide when ctx is None effectively provides static filtering in the description while still allowing dynamic filtering in the dialog based on actual input data.

python
>>> class ModelOptions(EnumParameterOptions):
...     LINEAR = ("Linear Regression", "Fits a linear model")
...     RANDOM_FOREST = ("Random Forest", "Ensemble tree model")
...     NEURAL_NET = ("Neural Network", "Deep learning model")
...
... def hide_by_model_support(context):
...     # Handle None context (no connection or description generation)
...     if context is None:
...         # Hide advanced option in description
...         return [ModelOptions.NEURAL_NET]
...
...     # Get input specifications for dialog filtering
...     specs = context.get_input_specs()
...     if not specs:
...         return []  # Hide nothing, show all
...
...     # Filter based on model capabilities from input
...     model_spec = specs[0]  # Assuming model is first input
...     supported = model_spec.get_supported_options()  # Hypothetical method
...
...     return [opt for opt in ModelOptions if opt.name not in supported]
...
... model_param = knext.EnumParameter(
...     label="Model Type",
...     description="Select the model to use.",
...     default_value=ModelOptions.LINEAR,  # Can use enum member directly
...     enum=ModelOptions,
...     hidden_choices=hide_by_model_support,
... )
method __init__(label: Optional[str] = None, description: Optional[str] = None, default_value: Union[str, EnumParameterOptions, DefaultValueProvider[Union[str, EnumParameterOptions]]] = None, enum: Optional[EnumParameterOptions] = None, validator: Optional[Callable[[str], None]] = None, since_version: Optional[Union[Version, str]] = None, is_advanced: bool = False, style: Optional[Style] = None, hidden_choices: Optional[Callable[[Optional[Any]], List[EnumParameterOptions]]] = None)
Parameters
  • label : str — The label of the parameter in the configuration dialog.
  • description : str — A description of the parameter, shown in the node description and dialog.
  • default_value : str, EnumParameterOptions, or callable — The default selected option: an enum member, its name, or a callable that derives it from the dialog creation context.
  • enum : EnumParameterOptions — The EnumParameterOptions subclass defining the available options.
  • validator : function — A function which validates the selected value and raises an exception if it is invalid.
  • since_version : str — The version at which this parameter was introduced. Can be omitted if the parameter is part of the first version of the node.
  • is_advanced : bool — Whether the parameter is shown in the advanced settings of the dialog.
  • style : EnumParameter.Style — Controls how the options are presented (radio buttons, value switch, or dropdown).
  • hidden_choices : Optional[Callable[[Optional[DialogCreationContext]], List[EnumParameterOptions]]] — Optional callable that filters which enum members are hidden in the dialog. The callable receives a DialogCreationContext (or None) and must return a list of enum members to hide. If None, empty list, or not provided, all enum members are shown.
method rule(condition: Condition, effect: Effect)

Add a rule that conditionally sets whether this parameter is visible or enabled in the dialog. This can be useful if this parameter should only be accessible if another parameter has a certain value.

Note

Rules can only depend on parameters on the same level, not in a child or parent parameter group.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     string_param = knext.StringParameter(
...         "String Param Title",
...         "String Param Title Description",
...         "default value"
...     )
...
...     # this parameter gets disabled if string_param is "foo" or "bar"
...     int_param = knext.IntParameter(
...         "Int Param Title",
...         "Int Param Description",
...     ).rule(knext.OneOf(string_param, ["foo", "bar"]), knext.Effect.DISABLE)
class knime.extension.EnumParameter.Style
attribute DROPDOWN = 'string'
attribute RADIO = 'radio'
attribute VALUE_SWITCH = 'valueSwitch'
method validator(func)

class knime.extension.EnumParameterOptions

A helper class for creating EnumParameter options, based on Python's Enum class.

Developers should subclass this class, and provide enumeration options as class attributes of the subclass, of the form OPTION_NAME = (OPTION_LABEL, OPTION_DESCRIPTION).

Enum option objects can be accessed as attributes of the EnumParameterOptions subclass, e.g. MyEnum.OPTION_NAME. Each option object has the following attributes:

  • name: the name of the class attribute, e.g. "OPTION_NAME", which is used as the selection constant;
  • label: the label of the option, displayed in the configuration dialogue of the node;
  • description: the description of the option, used along with the label to generate a list of the available options in the Node Description and in the configuration dialogue of the node.
Examples
python
>>> class CoffeeOptions(EnumParameterOptions):
...     CLASSIC = ("Classic", "The classic chocolatey taste, with notes of bitterness and wood.")
...     FRUITY = ("Fruity", "A fruity taste, with notes of berries and citrus.")
...     WATERY = ("Watery", "A watery taste, with notes of water and wetness.")
method __init__(label, description)
attribute description
classmethod get_all_options()

Returns a list of all options defined in the EnumParameterOptions subclass.

attribute label

class knime.extension.EnumSetParameter

Parameter class for multiple-choice parameter types. Expands the EnumParameter by enabling to select multiple enum constants.

A subclass of EnumParameterOptions should be provided as the enum parameter, which should contain class attributes of the form OPTION_NAME = (OPTION_LABEL, OPTION_DESCRIPTION). The corresponding option attributes can be accessed via MyOptions.OPTION_NAME.name, .label, and .description respectively.

The .name attribute of each option is used as the selection constant, e.g. MyOptions.OPTION_NAME.name == "OPTION_NAME".

Examples
python
>>> class CoffeeOptions(EnumParameterOptions):
...     CLASSIC = ("Classic", "The classic chocolatey taste, with notes of bitterness and wood.")
...     FRUITY = ("Fruity", "A fruity taste, with notes of berries and citrus.")
...     WATERY = ("Watery", "A watery taste, with notes of water and wetness.")
...
... coffee_selection_param = knext.EnumSetParameter(
...     label="Coffee Selection",
...     description="Select the types of coffee you like to drink.",
...     default_value=[CoffeeOptions.CLASSIC.name, CoffeeOptions.FRUITY.name],
...     enum=CoffeeOptions,
... )
method __init__(label: Optional[str] = None, description: Optional[str] = None, default_value: Union[List[str], DefaultValueProvider[List[str]]] = None, enum: Optional[EnumParameterOptions] = None, validator: Optional[Callable[[str], None]] = None, since_version: Optional[Union[Version, str]] = None, is_advanced: bool = False)
method rule(condition: Condition, effect: Effect)

Add a rule that conditionally sets whether this parameter is visible or enabled in the dialog. This can be useful if this parameter should only be accessible if another parameter has a certain value.

Note

Rules can only depend on parameters on the same level, not in a child or parent parameter group.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     string_param = knext.StringParameter(
...         "String Param Title",
...         "String Param Title Description",
...         "default value"
...     )
...
...     # this parameter gets disabled if string_param is "foo" or "bar"
...     int_param = knext.IntParameter(
...         "Int Param Title",
...         "Int Param Description",
...     ).rule(knext.OneOf(string_param, ["foo", "bar"]), knext.Effect.DISABLE)
method validator(func)

class knime.extension.DateTimeParameter

method __init__(label: Optional[str] = None, description: Optional[str] = None, default_value: Union[str, datetime.date] = None, validator = None, min_value: Union[str, datetime.date] = None, max_value: Union[str, datetime.date] = None, since_version = None, is_advanced: bool = False, show_date: bool = True, show_time: bool = False, show_seconds: bool = False, show_milliseconds: bool = False, timezone: str = None, date_format: str = None)

Parameter class for datetime types.

Parameters
  • label : str — The label of the parameter in the dialog.
  • description : str — The description of the parameter in the node description and dialog.
  • default_value : str or datetime — The default value of the parameter.
  • validator : function — A function which validates the value of the parameter.
  • min_value : str or datetime — The minimum value of the parameter.
  • max_value : str or datetime — The maximum value of the parameter.
  • since_version : str — The version at which this parameter was introduced. Can be omitted if the parameter is part of the first version of the node.
  • is_advanced : bool — Whether the parameter is advanced.
  • show_date : bool — Whether to show the date.
  • show_time : bool — Whether to show the time.
  • show_seconds : bool — Whether to show the seconds, ignored if show_time is False.
  • show_milliseconds : bool — Whether to show the milliseconds, ignored if show_time is False.
  • timezone : str — The timezone in a string format.
  • date_format : str — The date format to parse the default value.
method check_range(value)
method check_type(value)
attribute date_format
attribute max_value
attribute min_value
method rule(condition: Condition, effect: Effect)

Add a rule that conditionally sets whether this parameter is visible or enabled in the dialog. This can be useful if this parameter should only be accessible if another parameter has a certain value.

Note

Rules can only depend on parameters on the same level, not in a child or parent parameter group.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     string_param = knext.StringParameter(
...         "String Param Title",
...         "String Param Title Description",
...         "default value"
...     )
...
...     # this parameter gets disabled if string_param is "foo" or "bar"
...     int_param = knext.IntParameter(
...         "Int Param Title",
...         "Int Param Description",
...     ).rule(knext.OneOf(string_param, ["foo", "bar"]), knext.Effect.DISABLE)
attribute show_date
attribute show_milliseconds
attribute show_seconds
attribute show_time
attribute timezone
method validator(func)

To be used as a decorator for setting a validator function for a parameter. Note that 'func' will be encapsulated in '_validator' and will not be available in the namespace of the class.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     num_repetitions = knext.IntParameter(
...         label="Number of repetitions",
...         description="How often to repeat an action",
...         default_value=42
...     )
...     @num_repetitions.validator
...     def validate_reps(value):
...         if value > 100:
...             raise ValueError("Too many repetitions!")
...
...     def configure(args):
...         pass
...
...     def execute(args):
...         pass

class knime.extension.LocalPathParameter

Parameter class for local file path types. The path is represented as string.

Raises
  • TypeError — If the value is not a string.
  • ValueError — If the value is not a valid file path.
method __init__(label: Optional[str] = None, description: Optional[str] = None, placeholder_text: str = '', validator: Optional[Callable[[str], None]] = None, since_version: Optional[Union[Version, str]] = None, is_advanced: bool = False)
class dataclass knime.extension.LocalPathParameter.Choice
method __init__(id: str, label: str, description: str = '') → None
attribute description : str
attribute id : str
attribute label : str
attribute placeholder_text
method rule(condition: Condition, effect: Effect)

Add a rule that conditionally sets whether this parameter is visible or enabled in the dialog. This can be useful if this parameter should only be accessible if another parameter has a certain value.

Note

Rules can only depend on parameters on the same level, not in a child or parent parameter group.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     string_param = knext.StringParameter(
...         "String Param Title",
...         "String Param Title Description",
...         "default value"
...     )
...
...     # this parameter gets disabled if string_param is "foo" or "bar"
...     int_param = knext.IntParameter(
...         "Int Param Title",
...         "Int Param Description",
...     ).rule(knext.OneOf(string_param, ["foo", "bar"]), knext.Effect.DISABLE)
method validator(func)

To be used as a decorator for setting a validator function for a parameter. Note that 'func' will be encapsulated in '_validator' and will not be available in the namespace of the class.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     num_repetitions = knext.IntParameter(
...         label="Number of repetitions",
...         description="How often to repeat an action",
...         default_value=42
...     )
...     @num_repetitions.validator
...     def validate_reps(value):
...         if value > 100:
...             raise ValueError("Too many repetitions!")
...
...     def configure(args):
...         pass
...
...     def execute(args):
...         pass

class knime.extension.ParameterArray

A parameter that represents an array of parameters. Each element in the array is an instance of a parameter group.

Example

python
>>> @knext.parameter_group(label="Coffee Selections")
... class CoffeeSelections:
...     coffee_options = knext.StringParameter(
...         "Coffee Options",
...         "Enter the type of coffee you like to drink.",
...         default_value="Watery",
...     )
...
...     number_of_cups = knext.IntParameter(
...         "Number of Cups",
...         "Enter the number of cups of coffee you usually drink.",
...         default_value=5,
...     )
...
... coffee_selection = knext.ParameterArray(
...     label="Coffee Selections",
...     description="Select the type of coffee you like to drink.",
...     parameters=CoffeeSelections(),
...     since_version="5.3.1",
...     button_text="Add new selection",
...     array_title="Selections",
... )
method __init__(parameters, label: Optional[str] = None, description: Optional[str] = None, validator: Optional[Callable[[Any], None]] = None, since_version: Optional[Union[Version, str]] = None, is_advanced: bool = False, allow_reorder: bool = True, layout_direction: LayoutDirection = LayoutDirection.VERTICAL, button_text: Optional[str] = None, array_title: Optional[str] = None)
Parameters
  • parameters — A parameter group instance, created using the @parameter_group decorator. This defines the structure of each item in the array. The parameter group should contain the settings that each item in the array will have.
  • label : str — The label of the parameter in the dialog. It shows up as a headline of a section. If not specified, the name of the parameter will be used.
  • description : str — The description of the parameter in the node description.
  • validator : Optional[Callable] — A function which by default checks if there are any nested ParameterArray or ParameterGroup instances defined.
  • since_version : Union[Version, str] — A string or Version object representing the version since when the object is available (default is None).
  • is_advanced : bool — A boolean indicating if the object is advanced (default is False).
  • allow_reorder : bool — Whether the order of parameters in the array can be changed. Defaults to True.
  • layout_direction : (LayoutDirection, VERTICAL or HORIZONTAL) — Layout direction for the array. Can be HORIZONTAL or VERTICAL. Defaults to VERTICAL.
  • button_text : str — Text to display on the button for adding new parameters.
  • array_title : str — Title of the array of parameters. If not specified, the default "Group" will be used. An incremental suffix number is added to the title for each group added.
method rule(condition: Condition, effect: Effect)

Add a rule that conditionally sets whether this parameter is visible or enabled in the dialog. This can be useful if this parameter should only be accessible if another parameter has a certain value.

Note

Rules can only depend on parameters on the same level, not in a child or parent parameter group.

Examples
python
>>> @knext.node(args)
... class MyNode:
...     string_param = knext.StringParameter(
...         "String Param Title",
...         "String Param Title Description",
...         "default value"
...     )
...
...     # this parameter gets disabled if string_param is "foo" or "bar"
...     int_param = knext.IntParameter(
...         "Int Param Title",
...         "Int Param Description",
...     ).rule(knext.OneOf(string_param, ["foo", "bar"]), knext.Effect.DISABLE)
method validator(func)

Validation

Each parameter type supports custom validation via a property-like decorator. Use it to verify that a parameter value matches a criterion. Place the validator below the corresponding parameter definition.

Parameter Visibility Rules

Parameters can be marked as advanced (is_advanced=True) or made conditional on another parameter's value using rule().

class knime.extension.Condition

Abstract base class for all condition types of parameter visibility rules.

method to_dict(find_scope: Callable[[Any], _Scope], ctx)

Converts the Condition into a dict that is JSON serializable.

class knime.extension.And

A Condition that combines other Conditions with AND.

method __init__(*conditions: Condition) → None
method to_dict(find_scope: Callable[[Any], _Scope], ctx)

class knime.extension.Or

A Condition that combines other Conditions with OR.

method __init__(*conditions: Condition) → None
method to_dict(find_scope: Callable[[Any], _Scope], ctx)

class knime.extension.Contains

A Condition that evaluates to true if one of the values of the subject parameter is equal to the expected value.

method __init__(subject: Any, value: Any) → None
method to_dict(find_scope: Callable[[Any], _Scope], ctx)

class knime.extension.OneOf

A Condition that evaluates to true if the value of the subject parameter is equal to one of the expected values.

method __init__(subject: Any, values: List[Any]) → None
method to_dict(find_scope: Callable[[Any], _Scope], ctx)

class knime.extension.Effect

Encodes the effect a rule may cause.

attribute DISABLE = 'DISABLE'

Disable the parameter if the condition is true

attribute ENABLE = 'ENABLE'

Enable the parameter if the condition is true

attribute HIDE = 'HIDE'

Hide the parameter if the condition is true

attribute SHOW = 'SHOW'

Show the parameter if the condition is true

Parameter Groups

Combine parameters into groups visualized as sections in the configuration dialog. Group validators have access to all parameters in the group.

function knime.extension.parameter_group(label: str, since_version: Optional[Union[Version, str]] = None, is_advanced: bool = False, layout_direction: LayoutDirection = LayoutDirection.VERTICAL)

Decorator for classes implementing parameter groups. Parameter group classes can define parameters and other parameter groups both as class-level attributes and as instance-level attributed inside the __init__ method.

Parameter group classes can set values for their parameters inside the __init__ method during the constructor call (e.g. from the node containing the group, or another group). Note: when declaring the keyword arguments for the __init__ method of your parameter group class, you should refrain from using keywords from the following list of reserved keywords: since_version, is_advanced, and validator. These are used by the wrapper class in order to enable the backend functionality.

Group validators need to raise an exception if a values-based condition is violated, where values is a dictionary of parameter names and values. Group validators can be set using either of the following methods:

  • By implementing the "validate(self, values)" method inside the class definition of the group.
Examples
python
>>> def validate(self, values):
...     assert values['first_param'] + values['second_param'] < 100
  • By using the "@group_name.validator" decorator notation inside the class definition of the "parent" of the group. The decorator has an optional 'override' parameter, set to True by default, which overrides the "validate" method. If 'override' is set to False, the "validate" method, if defined, will be called first.
python
>>> @hyperparameters.validator(override=False)
... def validate_hyperparams(values):
...     assert values['first_param'] + values['second_param'] < 100

or

python
>>> @knext.parameter_group(label="My Settings")
... class MySettings:
...     name = knext.StringParameter("Name", "The name of the person", "Bario")
...     num_repetitions = knext.IntParameter("NumReps", "How often do we repeat?", 1, min_value=1)
...
...     @num_repetitions.validator
...     def reps_validator(value):
...         if value == 2:
...             raise ValueError("I don't like the number 2")
...
... @knext.node(args)
... class MyNodeWithSettings:
...     settings = MySettings()
...     def configure(args):
...         pass
...
...     def execute(args):
...         pass