Hi! Is there a way to access variable of other pi...
# questions
y
Hi! Is there a way to access variable of other pipelines with different namespace? For example: I have two pipelines. Output of one pipeline should be merged within Pipeline two. Both pipelines do have different namespaces. It works as expected when I use only one namespace:
Copy code
"""
This is a boilerplate pipeline 'data_aggregation'
generated using Kedro 1.0.0
"""

from kedro.pipeline import Node, Pipeline, node, pipeline  # noqa

from .nodes import (
    add_source,
    dropna,
    merge,
    rename,
)


def create_pipeline(**kwargs) -> Pipeline:
    return transform_123(**kwargs) + transform_ABC(**kwargs)


def transform_123(**kwargs) -> Pipeline:
    pipeline_instance = Pipeline(
        [
            node(
                func=add_source,
                inputs=["raw_input", "params:source_name"],
                outputs="with_source",
                name="add_source",
            ),
            node(
                func=rename,
                inputs=["with_source", "params:rename_mapper"],
                outputs="renamed",
            ),
            node(
                func=dropna,
                inputs=["renamed", "params:dropna"],
                outputs="no_na",
            ),
        ],
        namespace="namespace_123",
    )
    return pipeline_instance


def transform_ABC(**kwargs) -> Pipeline:
    pipeline_instance = Pipeline(
        [
            node(
                func=add_source,
                inputs=["namespace_ABC.raw_input", "params:namespace_ABC.source_name"],
                outputs="preprocessed",
                name="add_source",
            ),
            node(
                func=merge,
                inputs=["preprocessed", "namespace_123.no_na"],
                outputs="merged",
                name="merge_it",
            ),
        ],
    )
    return pipeline_instance
But as soon as I use another namespace kedro_viz won't show the correct input.
Copy code
"""
This is a boilerplate pipeline 'data_aggregation'
generated using Kedro 1.0.0
"""

from kedro.pipeline import Node, Pipeline, node, pipeline  # noqa

from .nodes import (
    add_source,
    dropna,
    merge,
    rename,
)


def create_pipeline(**kwargs) -> Pipeline:
    return transform_123(**kwargs) + transform_ABC(**kwargs)


def transform_123(**kwargs) -> Pipeline:
    pipeline_instance = Pipeline(
        [
            node(
                func=add_source,
                inputs=["raw_input", "params:source_name"],
                outputs="with_source",
                name="add_source",
            ),
            node(
                func=rename,
                inputs=["with_source", "params:rename_mapper"],
                outputs="renamed",
            ),
            node(
                func=dropna,
                inputs=["renamed", "params:dropna"],
                outputs="no_na",
            ),
        ],
        namespace="namespace_123",
    )
    return pipeline_instance


def transform_ABC(**kwargs) -> Pipeline:
    pipeline_instance = Pipeline(
        [
            node(
                func=add_source,
                inputs=["raw_input", "params:source_name"],
                outputs="preprocessed",
                name="add_source",
            ),
            node(
                func=merge,
                inputs=["preprocessed", "namespace_123.no_na"],
                outputs="merged",
                name="merge_it",
            ),
        ],
        namespace="namespace_ABC"
    )
    return pipeline_instance
r
Hi, if you need to access inputs or outputs that are outside a pipeline’s namespace, you can define them at the pipeline level. see this example here - https://docs.kedro.org/en/1.0.0/build/modular_pipelines/#how-to-structure-your-pipeline-creation
Copy code
# src/my_project/pipelines/{{pipeline_name}}/pipelines.py
from kedro.pipeline import Pipeline, Node

from .nodes import mean, mean_sos, variance
# Import node functions from nodes.py located in the same folder

def create_pipeline(**kwargs) -> Pipeline:
    return Pipeline(
        [
            Node(len, "xs", "n"),
            Node(mean, ["xs", "n"], "m", name="mean_node", tags="tag1"),
            Node(mean_sos, ["xs", "n"], "m2", name="mean_sos", tags=["tag1", "tag2"]),
            Node(variance, ["m", "m2"], "v", name="variance_node"),
        ],  # A list of nodes and pipelines combined into a new pipeline
        tags="tag3",  # Optional, each pipeline node will be tagged
        namespace="",  # Optional
        inputs={},  # Optional
        outputs={},  # Optional
        parameters={},  # Optional
    )
🄳 1
Copy code
def transform_123(**kwargs) -> Pipeline:
    return Pipeline(
        [
            node(
                func=add_source,
                inputs=["raw_input", "params:source_name"],
                outputs="with_source",
                name="add_source",
            ),
            node(
                func=rename,
                inputs=["with_source", "params:rename_mapper"],
                outputs="renamed",
            ),
            node(
                func=dropna,
                inputs=["renamed", "params:dropna"],
                outputs="no_na",
            ),
        ],
        namespace="namespace_123",
        outputs={"no_na"},  
    )