Skip to main content
Version: 25.2

snorkelflow.client.nodes.add_node

snorkelflow.client.nodes.add_node(application, input_node_uids=None, expected_op_type=None, node_config=None, output_node_uid=None, output_node_uids=None, node_cls='ApplicationNode', op_type=None, op_config=None, add_to_parent_block=False)

Adds a node to the graph. Must specify one of input_node_uids or output_node_uids to determine the location of the node.

Parameters

NameTypeDefaultInfo
applicationUnion[str, int]The name or UID of the application.
input_node_uidsOptional[List[int]]NoneThe list of input nodes. Use [-1] if your input node is the dataset node.
expected_op_typeOptional[str]NoneThe type of node.
node_configOptional[Dict[str, Any]]NoneA dictionary config for the node.
output_node_uidsOptional[List[int]]NoneAn optional list of output node ids.
output_node_uidOptional[int]NoneDeprecated. An optional output node id.
node_clsstr'ApplicationNode'The name of the node class.
op_typeOptional[str]NoneThe operator type to be committed, e.g., TruncatePreprocessor.
op_configOptional[Dict[str, Any]]NoneThe operator config, e.g., {“field”: “text”, “by”: “chars”, “length”: 5}. Use get_default_operator() to check required fields for built-in operators.
add_to_parent_blockOptional[bool]FalseThe boolean value to determine if the new node is added to the parent block. Note: in an application with a single existing block with input_node_uids=[-1], setting this parameter to True will result in a node added ahead of the block, not within it.

Returns

Information about the created node object

Return type

Dict[str, Any]

Examples

>>> # Add a place holder node
>>> sf.add_node(
>>> application=APP_NAME,
>>> input_node_uids=[input_node],
>>> expected_op_type="Featurizer",
>>> output_node_uids=[output_node],
>>> )
{'node_uid': <node_uid>, 'op_version_uid': None}

>>> # Add a committed node
>>> sf.add_node(
>>> application=APP_NAME,
>>> input_node_uids=[input_node],
>>> op_type="TruncatePreprocessor",
>>> op_config={"field": "text", "by": "chars", "length": 5},
>>> output_node_uids=[output_node],
>>> )
{'node_uid': <node_uid>, 'op_version_uid': <op_version_uid>}