Skip to content

Commit

Permalink
Add a tip on YAML anchors to docs on dataset layers (#2181)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-fedotov authored Nov 14, 2024
1 parent 49c9183 commit 5a7f11a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/source/kedro-viz_visualisation.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,43 @@ The visualisation now includes the layers:

![](./images/pipeline_visualisation_with_layers.png)

Duplicated definitions like:

```yaml
metadata:
kedro-viz:
layer: raw
```

can be avoided by leveraging YAML native syntax for anchors and aliases.

Use an anchor (`&`) first, to create a reusable piece of configuration:

```yaml
_raw_layer: &raw_layer
metadata:
kedro-viz:
layer: 01_raw
```

And then use aliases (`*`) to reference it:

```yaml
companies:
type: pandas.CSVDataset
filepath: data/01_raw/companies.csv
<<: *raw_layer
reviews:
type: pandas.CSVDataset
filepath: data/01_raw/reviews.csv
<<: *raw_layer
# Same for other datasets of the raw layer...
```

See [this example from the Kedro docs](https://docs.kedro.org/en/stable/data/data_catalog_yaml_examples.html#load-multiple-datasets-with-similar-configuration-using-yaml-anchors) for more details.

## Share a pipeline visualisation

You can save a pipeline structure within a Kedro-Viz visualisation directly from the terminal as follows:
Expand Down

0 comments on commit 5a7f11a

Please sign in to comment.