kedro.pipeline.node.Node¶
- class kedro.pipeline.node.Node(func, inputs, outputs, *, name=None, tags=None, confirms=None, namespace=None)[source]¶
Node
is an auxiliary class facilitating the operations required to run user-provided functions as part of Kedro pipelines.Attributes
Return dataset names to confirm as a list.
Exposes the underlying function of the node.
Return node inputs as a list, in the order required to bind them properly to the node's function.
Node's name.
Node's namespace.
Return node outputs as a list preserving the original order
Node's name.
Return the tags assigned to the node.
Methods
run
([inputs])Run this node using the provided inputs and return its results in a dictionary.
tag
(tags)Create a new
Node
which is an exact copy of the current one,- __init__(func, inputs, outputs, *, name=None, tags=None, confirms=None, namespace=None)[source]¶
Create a node in the pipeline by providing a function to be called along with variable names for inputs and/or outputs.
- Parameters:
func (Callable) – A function that corresponds to the node logic. The function should have at least one input or output.
inputs (str | list[str] | dict[str, str] | None) – The name or the list of the names of variables used as inputs to the function. The number of names should match the number of arguments in the definition of the provided function. When dict[str, str] is provided, variable names will be mapped to function argument names.
outputs (str | list[str] | dict[str, str] | None) – The name or the list of the names of variables used as outputs of the function. The number of names should match the number of outputs returned by the provided function. When dict[str, str] is provided, variable names will be mapped to the named outputs the function returns.
name (str | None) – Optional node name to be used when displaying the node in logs or any other visualisations. Valid node name must contain only letters, digits, hyphens, underscores and/or fullstops.
tags (str | Iterable[str] | None) – Optional set of tags to be applied to the node. Valid node tag must contain only letters, digits, hyphens, underscores and/or fullstops.
confirms (str | list[str] | None) – Optional name or the list of the names of the datasets that should be confirmed. This will result in calling
confirm()
method of the corresponding data set instance. Specified dataset names do not necessarily need to be present in the nodeinputs
oroutputs
.namespace (str | None) – Optional node namespace.
- Raises:
ValueError – Raised in the following cases: a) When the provided arguments do not conform to the format suggested by the type hint of the argument. b) When the node produces multiple outputs with the same name. c) When an input has the same name as an output. d) When the given node name violates the requirements: it must contain only letters, digits, hyphens, underscores and/or fullstops.
- property func: Callable¶
Exposes the underlying function of the node.
- Return type:
- Returns:
Return the underlying function of the node.
- property inputs: list[str]¶
Return node inputs as a list, in the order required to bind them properly to the node’s function.
- property name: str¶
Node’s name.
- Return type:
- Returns:
Node’s name if provided or the name of its function.
- property namespace: str | None¶
Node’s namespace.
- Return type:
str | None
- Returns:
String representing node’s namespace, typically from outer to inner scopes.
- property outputs: list[str]¶
- Return node outputs as a list preserving the original order
if possible.
- run(inputs=None)[source]¶
Run this node using the provided inputs and return its results in a dictionary.
- Parameters:
inputs (dict[str, Any] | None) – Dictionary of inputs as specified at the creation of the node.
- Raises:
ValueError – In the following cases: a) The node function inputs are incompatible with the node input definition. Example 1: node definition input is a list of 2 DataFrames, whereas only 1 was provided or 2 different ones were provided. b) The node function outputs are incompatible with the node output definition. Example 1: node function definition is a dictionary, whereas function returns a list. Example 2: node definition output is a list of 5 strings, whereas the function returns a list of 4 objects.
Exception – Any exception thrown during execution of the node.
- Return type:
- Returns:
All produced node outputs are returned in a dictionary, where the keys are defined by the node outputs.
- property short_name: str¶
Node’s name.
- Return type:
- Returns:
Returns a short, user-friendly name that is not guaranteed to be unique. The namespace is stripped out of the node name.