Hello, I’m working on the modular pipelines, and i...
# questions
j
Hello, I’m working on the modular pipelines, and it has some learning curves. I’d like to know if there is a better way. The code below does 1) creating namespace for an existing pipeline; 2) mapping some of namespaced data/param to those associated with the existing pipe. The way I did works, but can it be refactored to create a pipeline that does 1) and 2) all together?
Copy code
from kedro.pipeline import Pipeline, pipeline
from ..text_normalizing import create_pipeline as text_cleaning

text_cleaning_pipe = pipeline(
    text_cleaning(), 
    namespace="upsampling",
)

upsampling_text_cleaning_pipe = pipeline(
    [text_cleaning_pipe],
    inputs={
        "upsampling.sceptre_320_1510": "sceptre_320_all",
        "upsampling.abbreviation_dict": "abbreviation_dict",
        "upsampling.llm_expanded_abbreviation": "llm_expanded_abbreviation",
        "upsampling.frequency_dictionary_en": "frequency_dictionary_en",
        "upsampling.augmented_term_frequency": "augmented_term_frequency",
    },
    parameters={
        "params:upsampling.sceptre_processing_options.sub_sample_ratio": "params:sceptre_processing_options.sub_sample_ratio",
    },
)
h
Someone will reply to you shortly. In the meantime, this might help:
r
Hi @Jonghyun Yun, May be you can have a function which does this something like -
Copy code
def create_upsampling_text_cleaning_pipeline() -> Pipeline:
    return pipeline(
        text_cleaning(),
        namespace="upsampling",
        inputs={
            "sceptre_320_1510": "sceptre_320_all",
            "abbreviation_dict": "abbreviation_dict",
            "llm_expanded_abbreviation": "llm_expanded_abbreviation",
            "frequency_dictionary_en": "frequency_dictionary_en",
            "augmented_term_frequency": "augmented_term_frequency",
        },
        parameters={
            "params:sceptre_processing_options.sub_sample_ratio": "params:sceptre_processing_options.sub_sample_ratio",
        },
    )
👍 1
j
Thank you @Ravi Kumar Pilla! This makes sense to me.