This method create_link_graph
creates MRXLinkDagModel
class, which creates a DAG graph through components
and edges
information.
Create Link graph
create_link_graph(
components: Optional[List[MRXLinkComponentModel]] = None,
edges: Optional[List[MRXLinkDagEdgeModel]] = None,
) -> MRXLinkDagModel
-
Parameters
components
(list): List of components created using thecreate_link_component
method (create_link_component)edges
(list): List of edges created using thecreate_link_edge
method (create_link_edge)
-
Returns
MRXLinkDagModel(nodes=components, edges=edges)
-
Troubleshooting
- RuntimeError: This component name already exists in the pipeline.
- This occurs when a duplicate component ID is entered.
- ValueError: Component name is duplicated
- This occurs when a duplicate component name is entered.
- There is no component corresponding to parent_id '{parent_id}'
- This occurs when the parent component ID that is entered does not exist.
- There is no component corresponding to child_id '{child_id}'
- This occurs when the child component ID that is entered does not exist.
- RuntimeError: This component name already exists in the pipeline.
Example
from mrx_link.sdk.utils import *
# Code cell
code1 = """
x = 1
"""
code2 = """
y = 2
"""
code3 = """
print(f"{x=}, {y=}")
"""
if __name__ == "__main__":
# Create components
component1 = create_link_component(identifier="111-1", name="test", code=code1)
component2 = create_link_component(identifier="111-2", name="test2", code=code2)
component3 = create_link_component(identifier="111-3", name="test3", code=code3)
# Create edges
edge1 = create_link_edge(parent_id="111-1", child_id="111-3")
edge2 = create_link_edge(parent_id="111-2", child_id="111-3")
# Create a graph
graph = create_link_graph(
components=[component1, component2, component3],
edges=[edge1, edge2]
)