Skip to content

Commit

Permalink
Removed Output to a file docs section (#4421)
Browse files Browse the repository at this point in the history
Signed-off-by: Elena Khaustova <[email protected]>
  • Loading branch information
ElenaKhaustova authored Jan 14, 2025
1 parent 25bb58b commit 1536a2a
Showing 1 changed file with 0 additions and 93 deletions.
93 changes: 0 additions & 93 deletions docs/source/nodes_and_pipelines/run_a_pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,99 +233,6 @@ Out[11]: {'v': 0.666666666666667}
</details>



## Output to a file

We can also use IO to save outputs to a file. In this example, we define a custom `LambdaDataset` that would serialise the output to a file locally:

```{warning}
`LambdaDataset` has been deprecated and will be removed in Kedro `0.20.0`.
```

<details>
<summary><b>Click to expand</b></summary>


```python
def save(value):
with open("./data/07_model_output/variance.pickle", "wb") as f:
pickle.dump(value, f)


def load():
with open("./data/07_model_output/variance.pickle", "rb") as f:
return pickle.load(f)


pickler = LambdaDataset(load=load, save=save)
io.add("v", pickler)
```
</details>

It is important to make sure that the data catalog variable name `v` matches the name `v` in the pipeline definition.

Next we can confirm that this `LambdaDataset` behaves correctly:

<details>
<summary><b>Click to expand</b></summary>

```python
io.save("v", 5)
```

```python
io.load("v")
```

`Ouput`:

```Console
Out[12]: 5
```
</details>

Finally, let's run the pipeline again now and serialise the output:

<details>
<summary><b>Click to expand</b></summary>


```python
SequentialRunner().run(pipeline, catalog=io)
```

`Ouput`:

```console
Out[13]: {}
```
</details>

The output has been persisted to a local file so we don't see it directly, but it can be retrieved from the catalog:

<details>
<summary><b>Click to expand</b></summary>


```python
io.load("v")
```

`Ouput`:

```console
Out[14]: 0.666666666666667
```

```python
try:
os.remove("./data/07_model_output/variance.pickle")
except FileNotFoundError:
pass
```
</details>


## Configure `kedro run` arguments

The [Kedro CLI documentation](../development/commands_reference.md#run-the-project) lists the available CLI options for `kedro run`. You can alternatively supply a configuration file that contains the arguments to `kedro run`.
Expand Down

0 comments on commit 1536a2a

Please sign in to comment.