aixplain.modules.pipeline.designer.pipeline
DesignerPipeline Objects
class DesignerPipeline(Serializable)
add_node
def add_node(node: Node)
Add a node to the current pipeline.
This method will take care of setting the pipeline instance to the node and setting the node number if it's not set.
Arguments:
node
: the node
Returns:
the node
add_nodes
def add_nodes(*nodes: Node) -> List[Node]
Add multiple nodes to the current pipeline.
Arguments:
nodes
: the nodes
Returns:
the nodes
add_link
def add_link(link: Link) -> Link
Add a link to the current pipeline.
Arguments:
link
: the link
Returns:
the link
serialize
def serialize() -> dict
Serialize the pipeline to a dictionary. This method will serialize the
pipeline to a dictionary.
Returns:
the pipeline as a dictionary
validate_nodes
def validate_nodes()
Validate the linkage of the pipeline. This method will validate the
linkage of the pipeline by applying the following checks:
- All input nodes are linked out
- All output nodes are linked in
- All other nodes are linked in and out
Raises:
ValueError
: if the pipeline is not valid
is_param_linked
def is_param_linked(node, param)
Check if the param is linked to another node. This method will check
if the param is linked to another node.
Arguments:
node
: the nodeparam
: the param
Returns:
True if the param is linked, False otherwise
is_param_set
def is_param_set(node, param)
Check if the param is set. This method will check if the param is set
or linked to another node.
Arguments:
node
: the nodeparam
: the param
Returns:
True if the param is set, False otherwise
special_prompt_validation
def special_prompt_validation(node: Node)
This method will handle the special rule for asset nodes having
text-generation
function type where if any prompt variable exists
then the text
param is not required but the prompt param are.
Arguments:
node
: the node
Raises:
ValueError
: if the pipeline is not valid
validate_params
def validate_params()
This method will check if all required params are either set or linked
Raises:
ValueError
: if the pipeline is not valid
validate
def validate()
Validate the pipeline. This method will validate the pipeline by
series of checks:
- Validate all nodes are linked correctly
- Validate all required params are set or linked
Any other validation checks can be added here.
Raises:
ValueError
: if the pipeline is not valid
get_link
def get_link(from_node: int, to_node: int) -> Link
Get the link between two nodes. This method will return the link
between two nodes.
Arguments:
from_node
: the from node numberto_node
: the to node number
Returns:
the link
get_node
def get_node(node_number: int) -> Node
Get the node by its number. This method will return the node with the
given number.
Arguments:
node_number
: the node number
Returns:
the node
auto_infer
def auto_infer()
Automatically infer the data types of the nodes in the pipeline. This method will automatically infer the data types of the nodes in the pipeline by traversing the pipeline and setting the data types of the nodes based on the data types of the connected nodes.
asset
def asset(asset_id: str,
*args,
asset_class: Type[T] = AssetNode,
**kwargs) -> T
Shortcut to create an asset node for the current pipeline.
All params will be passed as keyword arguments to the node constructor.
Arguments:
kwargs
: keyword arguments
Returns:
the node
utility
def utility(asset_id: str,
*args,
asset_class: Type[T] = Utility,
**kwargs) -> T
Shortcut to create an utility nodes for the current pipeline.
All params will be passed as keyword arguments to the node constructor.
Arguments:
kwargs
: keyword arguments
Returns:
the node
decision
def decision(*args, **kwargs) -> Decision
Shortcut to create an decision node for the current pipeline.
All params will be passed as keyword arguments to the node constructor.
Arguments:
kwargs
: keyword arguments
Returns:
the node
script
def script(*args, **kwargs) -> Script
Shortcut to create an script node for the current pipeline.
All params will be passed as keyword arguments to the node constructor.
Arguments:
kwargs
: keyword arguments
Returns:
the node
input
def input(*args, **kwargs) -> Input
Shortcut to create an input node for the current pipeline.
All params will be passed as keyword arguments to the node constructor.
Arguments:
kwargs
: keyword arguments
Returns:
the node
output
def output(*args, **kwargs) -> Output
Shortcut to create an output node for the current pipeline.
All params will be passed as keyword arguments to the node constructor.
Arguments:
kwargs
: keyword arguments
Returns:
the node
router
def router(routes: Tuple[DataType, Node], *args, **kwargs) -> Router
Shortcut to create an decision node for the current pipeline.
All params will be passed as keyword arguments to the node constructor. The routes will be handled specially and will be converted to Route instances in a convenient way.
Arguments:
routes
: the routeskwargs
: keyword arguments
Returns:
the node
bare_reconstructor
def bare_reconstructor(*args, **kwargs) -> BareReconstructor
Shortcut to create an reconstructor node for the current pipeline.
All params will be passed as keyword arguments to the node constructor.
Arguments:
kwargs
: keyword arguments
Returns:
the node
bare_segmentor
def bare_segmentor(*args, **kwargs) -> BareSegmentor
Shortcut to create an segmentor node for the current pipeline.
All params will be passed as keyword arguments to the node constructor.
Arguments:
kwargs
: keyword arguments
Returns:
the node
metric
def metric(*args, **kwargs) -> BareMetric
Shortcut to create an metric node for the current pipeline.
All params will be passed as keyword arguments to the node constructor.
Arguments:
kwargs
: keyword arguments
Returns:
the node