Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipeline can't find nodes in kedro

Tags:

python

kedro

I was following pipelines tutorial, create all needed files, started the kedro with kedro run --node=preprocessing_data but got stuck with such error message:

ValueError: Pipeline does not contain nodes named ['preprocessing_data'].

If I run kedro without node parameter, I receive

kedro.context.context.KedroContextError: Pipeline contains no nodes

Contents of the files:

src/project/pipelines/data_engineering/nodes.py
def preprocess_data(data: SparkDataSet) -> None:
    print(data)
    return
src/project/pipelines/data_engineering/pipeline.py
def create_pipeline(**kwargs):
    return Pipeline(
        [
            node(
                func=preprocess_data,
                inputs="data",
                outputs="preprocessed_data",
                name="preprocessing_data",
            ),
        ]
    )
src/project/pipeline.py
def create_pipelines(**kwargs) -> Dict[str, Pipeline]:
    de_pipeline = de.create_pipeline()
    return {
        "de": de_pipeline,
        "__default__": Pipeline([])
    }
like image 576
eawer Avatar asked Dec 17 '22 14:12

eawer


2 Answers

I think it looks like you need to have the pipeline in __default__. e.g.

def create_pipelines(**kwargs) -> Dict[str, Pipeline]:
    de_pipeline = de.create_pipeline()
    return {
        "de": data_engineering_pipeline,
        "__default__": data_engineering_pipeline
    }

Then kedro run --node=preprocessing_data works for me.

like image 156
mayurc Avatar answered Dec 31 '22 20:12

mayurc


Mayurc is correct there are no nodes because your __default__ pipeline is empty. Another option is to run just the de pipeline with the cli.

kedro run --pipeline de

You can find this option and more in the help text of the run command.

$ kedro run --help

Usage: kedro run [OPTIONS]

  Run the pipeline.

Options:
  --from-inputs TEXT        A list of dataset names which should be used as a
                            starting point.
  --from-nodes TEXT         A list of node names which should be used as a
                            starting point.
  --to-nodes TEXT           A list of node names which should be used as an
                            end point.
  -n, --node TEXT           Run only nodes with specified names.
  -r, --runner TEXT         Specify a runner that you want to run the pipeline
                            with.
                            This option cannot be used together with
                            --parallel.
  -p, --parallel            Run the pipeline using the `ParallelRunner`.
                            If
                            not specified, use the `SequentialRunner`. This
                            flag cannot be used together
                            with --runner.
  -e, --env TEXT            Run the pipeline in a configured environment. If
                            not specified,
                            pipeline will run using environment
                            `local`.
  -t, --tag TEXT            Construct the pipeline using only nodes which have
                            this tag
                            attached. Option can be used multiple
                            times, what results in a
                            pipeline constructed from
                            nodes having any of those tags.
  -lv, --load-version TEXT  Specify a particular dataset version (timestamp)
                            for loading.
  --pipeline TEXT           Name of the modular pipeline to run.
                            If not set,
                            the project pipeline is run by default.
  -c, --config FILE         Specify a YAML configuration file to load the run
                            command arguments from. If command line arguments
                            are provided, they will
                            override the loaded ones.
  --params TEXT             Specify extra parameters that you want to pass
                            to
                            the context initializer. Items must be separated
                            by comma, keys - by colon,
                            example:
                            param1:value1,param2:value2. Each parameter is
                            split by the first comma,
                            so parameter values are
                            allowed to contain colons, parameter keys are not.
  -h, --help                Show this message and exit.

Posted a second answer as the full help output did not fit in a comment.

like image 27
Waylon Walker Avatar answered Dec 31 '22 18:12

Waylon Walker