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
Parameters
Returns
Returns
Information about the created node object
Return type
Return type
Dict[str, Any]
Name Type Default Info application Union[str, int]
The name or UID of the application. input_node_uids Optional[List[int]]
None
The list of input nodes. Use [-1] if your input node is the dataset node. expected_op_type Optional[str]
None
The type of node. node_config Optional[Dict[str, Any]]
None
A dictionary config for the node. output_node_uids Optional[List[int]]
None
An optional list of output node ids. output_node_uid Optional[int]
None
Deprecated. An optional output node id. node_cls str
'ApplicationNode'
The name of the node class. op_type Optional[str]
None
The operator type to be committed, e.g., TruncatePreprocessor. op_config Optional[Dict[str, Any]]
None
The 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_block Optional[bool]
False
The 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. 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>}