Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions aixplain/modules/pipeline/designer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,26 @@ def __init__(
if isinstance(to_param, Param):
to_param = to_param.code

assert from_param in from_node.outputs, \
"Invalid from param. "\
assert from_param in from_node.outputs, (
"Invalid from param. "
"Make sure all input params are already linked accordingly"
)

fp_instance = from_node.outputs[from_param]
from .nodes import Decision
if (isinstance(to_node, Decision) and
to_param == to_node.inputs.passthrough.code):
to_node.outputs.create_param(from_param,
fp_instance.data_type,
is_required=fp_instance.is_required)

if (
isinstance(to_node, Decision)
and to_param == to_node.inputs.passthrough.code
):
if from_param not in to_node.outputs:
to_node.outputs.create_param(
from_param,
fp_instance.data_type,
is_required=fp_instance.is_required,
)
else:
to_node.outputs[from_param].data_type = fp_instance.data_type

assert to_param in to_node.inputs, "Invalid to param"

Expand Down Expand Up @@ -244,9 +253,7 @@ def __init__(self, node: "Node", *args, **kwargs):
def add_param(self, param: Param) -> None:
# check if param already registered
if param in self:
raise ValueError(
f"Parameter with code '{param.code}' already exists."
)
raise ValueError(f"Parameter with code '{param.code}' already exists.")
self._params.append(param)
# also set attribute on the node dynamically if there's no
# any attribute with the same name
Expand Down Expand Up @@ -364,9 +371,7 @@ def attach_to(self, pipeline: "DesignerPipeline"):
:param pipeline: the pipeline
"""
assert not self.pipeline, "Node already attached to a pipeline"
assert (
self not in pipeline.nodes
), "Node already attached to a pipeline"
assert self not in pipeline.nodes, "Node already attached to a pipeline"
assert self.type, "Node type not set"

self.pipeline = pipeline
Expand Down