Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 16 additions & 1 deletion aixplain/factories/pipeline_factory/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,23 @@ def build_from_response(response: Dict, load_architecture: bool = False) -> Pipe
node.label = node_json["label"]
pipeline.add_node(node)

# Decision nodes' output parameters are defined based on their
# input parameters linked. So here we have to make sure that
# decision nodes (having passthrough parameter) should be first
# linked
link_jsons = response["links"][:]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you remove the [:]?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because we're copying the list to modify for later.

decision_links = []
for link_json in link_jsons:
for pm in link_json["paramMapping"]:
if pm["to"] == "passthrough":
decision_link_index = link_jsons.index(link_json)
decision_link = link_jsons.pop(decision_link_index)
decision_links.append(decision_link)

link_jsons = decision_links + link_jsons

# instantiating links
for link_json in response["links"]:
for link_json in link_jsons:
for param_mapping in link_json["paramMapping"]:
link = Link(
from_node=pipeline.get_node(link_json["from"]),
Expand Down
17 changes: 14 additions & 3 deletions aixplain/modules/pipeline/designer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,25 @@ def __init__(
pipeline: "DesignerPipeline" = None,
):

assert from_param in from_node.outputs, "Invalid from param"
assert to_param in to_node.inputs, "Invalid to param"

if isinstance(from_param, Param):
from_param = from_param.code
if isinstance(to_param, Param):
to_param = to_param.code

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)

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

self.from_node = from_node
self.to_node = to_node
self.from_param = from_param
Expand Down
10 changes: 7 additions & 3 deletions aixplain/modules/pipeline/designer/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,15 @@ def __init__(self, value: DataType, path: List[Union[Node, int]], operation: Ope
self.operation = operation
self.type = type

if not self.path:
raise ValueError("Path is not valid, should be a list of nodes")
# Path can be an empty list in case the user has a valid case
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is related with the commented section, why we need to remove?

# if not self.path:
# raise ValueError("Path is not valid, should be a list of nodes")

# convert nodes to node numbers if they are nodes
self.path = [node.number if isinstance(node, Node) else node for node in self.path]
self.path = [
node.number if isinstance(node, Node) else node
for node in self.path
]

def serialize(self) -> dict:
return {
Expand Down