Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise modular pipelines docs #3948

Merged
merged 33 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
18a46ee
Docs update
DimedS Jun 11, 2024
8a7d370
Docs update
DimedS Jun 11, 2024
9fbf6b3
Merge branch 'main' into 1998-revise-the-modular-pipelines-docs
DimedS Jun 11, 2024
653dcde
Fix header
DimedS Jun 11, 2024
53f94fe
Change filename
DimedS Jun 11, 2024
8678eb7
Fix external link
DimedS Jun 11, 2024
23b0989
Fix external link
DimedS Jun 11, 2024
682efb1
Fix external links
DimedS Jun 11, 2024
c8e75a1
Apply suggestions from code review
DimedS Jun 17, 2024
9ba96fc
Merge branch 'main' into 1998-revise-the-modular-pipelines-docs
DimedS Jun 17, 2024
7c93b58
Address review comments
DimedS Jun 17, 2024
bdae1ec
Address review comments
DimedS Jun 18, 2024
3d37b5c
Apply suggestions from code review
DimedS Jun 20, 2024
c907c28
Address review comments
DimedS Jun 20, 2024
5999491
Merge branch 'main' into 1998-revise-the-modular-pipelines-docs
DimedS Jun 20, 2024
e235a24
Fix old links
DimedS Jun 20, 2024
7b06d9c
Apply suggestions from code review
DimedS Jun 21, 2024
952c4fa
Address review comments
DimedS Jun 21, 2024
8fcc3c4
Address review comments
DimedS Jun 24, 2024
a58d31e
Apply suggestions from code review
DimedS Jun 26, 2024
77ed3aa
Revise namespaces
DimedS Jun 28, 2024
4e2c8ac
Revise namespaces examples
DimedS Jun 28, 2024
faa08b2
Apply suggestions from code review
DimedS Jun 28, 2024
84f444f
Address review comments
DimedS Jun 28, 2024
aa4a3c2
Apply suggestions from code review
DimedS Jul 1, 2024
0ac37be
Address review comments
DimedS Jul 1, 2024
2fbf15e
Address review comments
DimedS Jul 1, 2024
0c14ce2
Address review comments
DimedS Jul 1, 2024
6b36ab9
Address review comments
DimedS Jul 1, 2024
bc04d86
Remove cooking example
DimedS Jul 1, 2024
c46dab3
Apply suggestions from code review
DimedS Jul 2, 2024
1cfc4d7
Add comments to create_pipeline func
DimedS Jul 2, 2024
cf63f67
Merge branch 'main' into 1998-revise-the-modular-pipelines-docs
DimedS Jul 2, 2024
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
4 changes: 2 additions & 2 deletions docs/source/faq/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@

## Nodes and pipelines

* [How do I create a modular pipeline](../nodes_and_pipelines/modular_pipelines.md#how-do-i-create-a-modular-pipeline)?

* [How can I create a new blank pipeline using the `kedro pipeline create` command](../nodes_and_pipelines/modular_pipelines.md#how-to-create-a-new-blank-pipeline-using-the-kedro-pipeline-create-command)?

Check warning on line 55 in docs/source/faq/faq.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/faq/faq.md#L55

[Kedro.pronouns] Avoid first-person singular pronouns such as 'I'.
Raw output
{"message": "[Kedro.pronouns] Avoid first-person singular pronouns such as 'I'.", "location": {"path": "docs/source/faq/faq.md", "range": {"start": {"line": 55, "column": 12}}}, "severity": "WARNING"}
DimedS marked this conversation as resolved.
Show resolved Hide resolved
* [How can I reuse my pipelines with namespaces](../nodes_and_pipelines/namespaces.md)?

Check warning on line 56 in docs/source/faq/faq.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/faq/faq.md#L56

[Kedro.pronouns] Avoid first-person singular pronouns such as 'I'.
Raw output
{"message": "[Kedro.pronouns] Avoid first-person singular pronouns such as 'I'.", "location": {"path": "docs/source/faq/faq.md", "range": {"start": {"line": 56, "column": 12}}}, "severity": "WARNING"}

Check warning on line 56 in docs/source/faq/faq.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/faq/faq.md#L56

[Kedro.pronouns] Avoid first-person singular pronouns such as 'my'.
Raw output
{"message": "[Kedro.pronouns] Avoid first-person singular pronouns such as 'my'.", "location": {"path": "docs/source/faq/faq.md", "range": {"start": {"line": 56, "column": 20}}}, "severity": "WARNING"}
DimedS marked this conversation as resolved.
Show resolved Hide resolved
* [Can I use generator functions in a node](../nodes_and_pipelines/nodes.md#how-to-use-generator-functions-in-a-node)?

## What is data engineering convention?
Expand Down
Binary file modified docs/source/meta/images/cook_disjointed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/meta/images/cook_joined.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/meta/images/cook_no_namespace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/meta/images/cook_params.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/source/nodes_and_pipelines/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
nodes
pipeline_introduction
modular_pipelines
namespaces
pipeline_registry
micro_packaging
run_a_pipeline
Expand Down
335 changes: 79 additions & 256 deletions docs/source/nodes_and_pipelines/modular_pipelines.md

Large diffs are not rendered by default.

212 changes: 212 additions & 0 deletions docs/source/nodes_and_pipelines/namespaces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
# Reuse pipelines with namespaces

## How to reuse your pipelines

If you want to create a new pipeline that performs similar tasks with different inputs/outputs/parameters as your existing pipeline (e.g., `data_science` pipeline from our [Spaceflights tutorial](../tutorial/add_another_pipeline.md#data-science-pipeline)), you can use the same `pipeline()` creation function as described in [How to structure your pipeline creation](modular_pipelines.md#how-to-structure-your-pipeline-creation). This function allows you to overwrite inputs, outputs, and parameters. Your new pipeline creation code should look like this:

Check notice on line 5 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L5

[Kedro.sentencelength] Try to keep your sentence length to 30 words or fewer.
Raw output
{"message": "[Kedro.sentencelength] Try to keep your sentence length to 30 words or fewer.", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 5, "column": 1}}}, "severity": "INFO"}

Check warning on line 5 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L5

[Kedro.abbreviations] Use 'for example' instead of abbreviations like 'e.g.,'.
Raw output
{"message": "[Kedro.abbreviations] Use 'for example' instead of abbreviations like 'e.g.,'.", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 5, "column": 134}}}, "severity": "WARNING"}
DimedS marked this conversation as resolved.
Show resolved Hide resolved

```python
def create_new_pipeline(**kwargs) -> Pipeline:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this PR overall uses less specific names than the current docs, which at least to me is an impact on docs quality. Compare:

create_new_pipeline

to:

final_pipeline = (
    cook_breakfast_pipeline
    + eat_breakfast_pipeline
    + cook_lunch_pipeline
    + eat_lunch_pipeline
)

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated it to create_pipeline(). If I understood correctly, the name create_pipeline() is important (although it is not specific) because otherwise, the pipeline will not be autodiscovered and executed during kedro new (see Kedro documentation). If you see any other examples with less specific names, please let me know and I would be happy to fix them as well.

return pipeline(
[data_science], # Name of the existing pipeline
inputs = {"old_input_df_name" : "new_input_df_name"}, # Mapping old input to new input
outputs = {"old_output_df_name" : "new_output_df_name"}, # Mapping old output to new output
parameters = {"params: test_size1": "params: test_size2"}, # Updating parameters
)
```
This means you can easily create multiple pipelines based on the `data_science` pipeline to test different approaches with various input datasets and model training parameters.

Check warning on line 16 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L16

[Kedro.words] Use '' instead of 'easily'.
Raw output
{"message": "[Kedro.words] Use '' instead of 'easily'.", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 16, "column": 20}}}, "severity": "WARNING"}

Check warning on line 16 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L16

[Kedro.weaselwords] 'easily' is a weasel word!
Raw output
{"message": "[Kedro.weaselwords] 'easily' is a weasel word!", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 16, "column": 20}}}, "severity": "WARNING"}

Check warning on line 16 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L16

[Kedro.toowordy] 'multiple' is too wordy
Raw output
{"message": "[Kedro.toowordy] 'multiple' is too wordy", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 16, "column": 34}}}, "severity": "WARNING"}

## What is a Namespace

Check warning on line 18 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L18

[Kedro.headings] 'What is a Namespace' should use sentence-style capitalization.
Raw output
{"message": "[Kedro.headings] 'What is a Namespace' should use sentence-style capitalization.", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 18, "column": 4}}}, "severity": "WARNING"}
DimedS marked this conversation as resolved.
Show resolved Hide resolved

If you need to try different options for training your model, constantly overwriting your outputs for each new pipeline can become tedious. Each model's results (outputs) should be saved in new objects, which can be annoying to manage manually. Namespaces are a perfect solution for this. By setting a `namespace="namespace_name"` parameter for each new pipeline (based on an existing pipeline), you achieve automatic output and node isolation. This is done by adding a `namespace_name` prefix to each pipeline node and output dataset. Your pipeline creation code will look like this:

```python
def create_new_pipeline(**kwargs) -> Pipeline:
return pipeline(
[data_science], # Name of the existing pipeline
inputs={"old_input_df_name": "new_input_df_name"}, # Mapping old input to new input
parameters={"params:test_size1": "params:test_size2"}, # Updating parameters
namespace="alternative_approach", # Setting the namespace name
)
```
In this example:
* The `data_science` pipeline is reused and namespaced under `alternative_approach`.
* The inputs and parameters are mapped to new names/values.
* The namespace parameter ensures that all nodes and outputs in this pipeline are prefixed with `alternative_approach.`, isolating them from other pipelines.

Namespace methods:
* You can use `kedro run --namespace = namespace_name` to run only the specific namespace

Check warning on line 37 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L37

[Kedro.weaselwords] 'only' is a weasel word!
Raw output
{"message": "[Kedro.weaselwords] 'only' is a weasel word!", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 37, "column": 63}}}, "severity": "WARNING"}
* [Kedro-Viz](https://demo.kedro.org) accelerates development by rendering namespaced pipelines as collapsible 'super nodes'.


## Providing pipeline specific dependencies

* A pipeline **might** have external dependencies specified in a local `requirements.txt` file.
* Pipeline specific dependencies are scooped up during the [micro-packaging](micro_packaging.md) process.
* These dependencies need to be manually installed using `pip`:
```bash
pip install -r requirements.txt
```
DimedS marked this conversation as resolved.
Show resolved Hide resolved

## Example: Combining disconnected pipelines

Check warning on line 50 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L50

[Kedro.headings] 'Example: Combining disconnected pipelines' should use sentence-style capitalization.
Raw output
{"message": "[Kedro.headings] 'Example: Combining disconnected pipelines' should use sentence-style capitalization.", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 50, "column": 4}}}, "severity": "WARNING"}

Sometimes two pipelines must be connected, but do not share any catalog dependencies. In this example, there is a `lunch_pipeline`, which makes us lunch. The 'verbs', `defrost` and `eat`, are Python functions and the inputs/outputs are food at different points of the process (`frozen`, `thawed` and `food`).
Copy link
Contributor

Choose a reason for hiding this comment

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

thawed is not present in the example at all

Copy link
Member Author

Choose a reason for hiding this comment

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

Decided to remove the cooking examples.


```python
cook_pipeline = pipeline(
[
node(func=defrost, inputs="frozen_veg", outputs="veg"),
node(func=grill, inputs="veg", outputs="grilled_veg"),
]
)

lunch_pipeline = pipeline([node(func=eat, inputs="food", outputs=None)])

cook_pipeline + lunch_pipeline
```

This combination will visualise since it's valid pre-runtime, but it will not run since `food` is not an output of the `cook_pipeline` because the output of the `cook_pipeline` is `grilled_veg`:

![disjoined](../meta/images/cook_disjointed.png)

* Combining `cook_pipeline + lunch_pipeline` will not work since `food` doesn't exist as an output of the `cook_pipeline`.
* In this case, we will need to map `grilled_veg` to the expected input of `food`.

The wrapper allows us to provide a mapping and fix this disconnect.

```python
from kedro.pipeline.modular_pipeline import pipeline

prep_pipeline = pipeline(pipe=cook_pipeline, outputs={"grilled_veg": "food"})

meal_pipeline = prep_pipeline + lunch_pipeline
```

Providing this input/output override will join up the pipeline nicely:

![joined](../meta/images/cook_joined.png)

```{note}
In this example we have used the `+` operator to join two pipelines. You can also use `sum()` or pass a list of pipelines to the `pipe` argument.
```


## Example: Using a modular pipeline multiple times

Check warning on line 93 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L93

[Kedro.toowordy] 'multiple' is too wordy
Raw output
{"message": "[Kedro.toowordy] 'multiple' is too wordy", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 93, "column": 38}}}, "severity": "WARNING"}

Reusing pipelines for slightly different purposes can be a real accelerator for teams and organisations when they reach a certain scale. In the real world, one could imagine pipelines with responsibilities like profiling or feature engineering being reused within the same project or even across projects via [micro-packaging](micro_packaging.md).

Check warning on line 95 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L95

[Kedro.words] Use 'with' or 'through' instead of 'via'.
Raw output
{"message": "[Kedro.words] Use 'with' or 'through' instead of 'via'.", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 95, "column": 306}}}, "severity": "WARNING"}

* In an ideal world, we would like to use the `cook_pipeline` twice as you would `defrost` and `grill` multiple meals beyond the `veg` currently hard-coded.

Check warning on line 97 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L97

[Kedro.toowordy] 'multiple' is too wordy
Raw output
{"message": "[Kedro.toowordy] 'multiple' is too wordy", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 97, "column": 104}}}, "severity": "WARNING"}

Check warning on line 97 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L97

[Kedro.weaselwords] 'currently' is a weasel word!
Raw output
{"message": "[Kedro.weaselwords] 'currently' is a weasel word!", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 97, "column": 136}}}, "severity": "WARNING"}
* Namespaces allow you to instantiate the same pipeline multiple times and keep operations isolated.

Check warning on line 98 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L98

[Kedro.toowordy] 'multiple' is too wordy
Raw output
{"message": "[Kedro.toowordy] 'multiple' is too wordy", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 98, "column": 57}}}, "severity": "WARNING"}
* Like one provides arguments to a class' constructor, you can provide overriding inputs/outputs/parameters to the `pipeline()` wrapper.

```{note}
The set of overriding inputs and outputs must be a subset of the reused pipeline's "free" inputs and outputs, respectively. A free input is an input that isn't generated by a node in the pipeline, while a free output is an output that isn't consumed by a node in the pipeline. {py:meth}`Pipeline.inputs() <kedro.pipeline.Pipeline.inputs>` and {py:meth}`Pipeline.outputs() <kedro.pipeline.Pipeline.outputs>` can be used to list a pipeline's free inputs and outputs, respectively.
```

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need both cooking and data science example to demonstrate how namespaces work?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree with that. We want to move away from the cooking example and shift to something more practical, based on our spaceflights-pandas starter. I previously kept the cooking example, but let's go ahead and remove it.

```python
cook_pipeline = pipeline(
[
node(func=defrost, inputs="frozen_veg", outputs="veg", name="defrost_node"),
node(func=grill, inputs="veg", outputs="grilled_veg"),
]
)

eat_breakfast_pipeline = pipeline(
[node(func=eat_breakfast, inputs="breakfast_food", outputs=None)]
)
eat_lunch_pipeline = pipeline([node(func=eat_lunch, inputs="lunch_food", outputs=None)])

cook_pipeline + eat_breakfast_pipeline + eat_lunch_pipeline
```

If we visualise the snippet above, we see a disjointed pipeline:

* We need to "defrost" two different types of food via different pipelines.

Check warning on line 123 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L123

[Kedro.words] Use 'with' or 'through' instead of 'via'.
Raw output
{"message": "[Kedro.words] Use 'with' or 'through' instead of 'via'.", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 123, "column": 52}}}, "severity": "WARNING"}
* We cannot use the `cook_pipeline` twice because the internal dataset names will conflict.
* Mapping all datasets via the `pipeline()` wrapper will also cause conflicts.

Check warning on line 125 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L125

[Kedro.words] Use 'with' or 'through' instead of 'via'.
Raw output
{"message": "[Kedro.words] Use 'with' or 'through' instead of 'via'.", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 125, "column": 24}}}, "severity": "WARNING"}

![cook no namespace](../meta/images/cook_no_namespace.png)

Adding namespaces solves this issue:

```python
cook_breakfast_pipeline = pipeline(
pipe=cook_pipeline,
inputs="frozen_veg", # inputs stay the same, don't namespace
outputs={"grilled_veg": "breakfast_food"},
namespace="breakfast",
)
cook_lunch_pipeline = pipeline(
pipe=cook_pipeline,
inputs="frozen_veg", # inputs stay the same, don't namespace
outputs={"grilled_veg": "lunch_food"},
namespace="lunch",
)

final_pipeline = (
cook_breakfast_pipeline
+ eat_breakfast_pipeline
+ cook_lunch_pipeline
+ eat_lunch_pipeline
)
```

* `namespace="lunch"` renames all datasets and nodes, prefixing them with `"lunch."`.
* The datasets that we explicitly "freeze" (`frozen_veg`) or remap (`grilled_veg`) are not affected/prefixed.
* Remapping free outputs is required since "breakfast_food" and "lunch_food" are the names expected by the `eat_breakfast_pipeline` and `eat_lunch_pipeline` respectively.

Check warning on line 155 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L155

[Kedro.Spellings] Did you really mean 'breakfast_food'?
Raw output
{"message": "[Kedro.Spellings] Did you really mean 'breakfast_food'?", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 155, "column": 45}}}, "severity": "WARNING"}

Check warning on line 155 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L155

[Kedro.Spellings] Did you really mean 'lunch_food'?
Raw output
{"message": "[Kedro.Spellings] Did you really mean 'lunch_food'?", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 155, "column": 66}}}, "severity": "WARNING"}
* The resulting pipeline now has two separate nodes, `breakfast.defrost_node` and `lunch.defrost_node`.
* Also two separate datasets `breakfast.veg` and `lunch.veg` connect the nodes inside the pipelines, causing no confusion between them.

![namespaced](../meta/images/cook_namespaced.gif)

* Visualising the `final_pipeline` highlights how namespaces become 'super nodes' which encapsulate the wrapped pipeline.
* This example demonstrates how we can reuse the same `cook_pipeline` with slightly different arguments.
* Namespaces can also be arbitrarily nested with the `.` character.
* `kedro run --namespace=<namespace>` could be used to only run nodes with a specific namespace.

Check warning on line 164 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L164

[Kedro.weaselwords] 'only' is a weasel word!
Raw output
{"message": "[Kedro.weaselwords] 'only' is a weasel word!", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 164, "column": 56}}}, "severity": "WARNING"}

```{note}
`parameters` references will not be namespaced, but `params:` references will.
```

## Example: How to reuse a pipeline with different parameters

Mapping parameter values is very similar to the way we map inputs and outputs.

Check warning on line 172 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L172

[Kedro.words] Use '' instead of 'very'.
Raw output
{"message": "[Kedro.words] Use '' instead of 'very'.", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 172, "column": 30}}}, "severity": "WARNING"}

Check warning on line 172 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L172

[Kedro.weaselwords] 'very' is a weasel word!
Raw output
{"message": "[Kedro.weaselwords] 'very' is a weasel word!", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 172, "column": 30}}}, "severity": "WARNING"}

Check warning on line 172 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L172

[Kedro.toowordy] 'similar to' is too wordy
Raw output
{"message": "[Kedro.toowordy] 'similar to' is too wordy", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 172, "column": 35}}}, "severity": "WARNING"}

* We instantiate the `template_pipeline` twice, but pass in different parameters.
* `input1` and `input2` are 'frozen' and thus shared in both instances.
* `params:override_me` does not actually exist and is designed to be overridden in both cases.
* Providing a namespace isolates the intermediate operation and visualises nicely.

```python
template_pipeline = pipeline(
[
node(
func=node_func1,
inputs=["input1", "input2", "params:override_me"],
outputs="intermediary_output",
),
node(
func=node_func2,
inputs="intermediary_output",
outputs="output",
),
]
)

alpha_pipeline = pipeline(
pipe=template_pipeline,
inputs={"input1", "input2"},
parameters={"params:override_me": "params:alpha"},
namespace="alpha",
)

beta_pipeline = pipeline(
pipe=template_pipeline,
inputs={"input1", "input2"},
parameters={"params:override_me": "params:beta"},
namespace="beta",
)

final_pipeline = alpha_pipeline + beta_pipeline
```

![namespaced_params](../meta/images/cook_params.png)

Check warning on line 212 in docs/source/nodes_and_pipelines/namespaces.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/nodes_and_pipelines/namespaces.md#L212

[Kedro.Spellings] Did you really mean 'namespaced_params'?
Raw output
{"message": "[Kedro.Spellings] Did you really mean 'namespaced_params'?", "location": {"path": "docs/source/nodes_and_pipelines/namespaces.md", "range": {"start": {"line": 212, "column": 3}}}, "severity": "WARNING"}
Loading