Skip to content

Commit

Permalink
Update %load_node docs to make requirements more explicit (#3658)
Browse files Browse the repository at this point in the history
* Update %load_node docs to make requirements more explicit

Signed-off-by: Nok Lam Chan <[email protected]>

* add links

Signed-off-by: Nok Lam Chan <[email protected]>

* lint

Signed-off-by: Nok <[email protected]>

* changes base on review

Signed-off-by: Nok <[email protected]>

* revise base on review comments

Signed-off-by: Nok <[email protected]>

* add SEO friendly title and expand the explanation

Signed-off-by: Nok Lam Chan <[email protected]>

* revert mypy hints

Signed-off-by: Nok Lam Chan <[email protected]>

* fix merge error

Signed-off-by: Nok Lam Chan <[email protected]>

* newline

Signed-off-by: Nok Lam Chan <[email protected]>

* whitespace

Signed-off-by: Nok Lam Chan <[email protected]>

* fix grammar

Signed-off-by: Nok <[email protected]>

---------

Signed-off-by: Nok Lam Chan <[email protected]>
Signed-off-by: Nok <[email protected]>
  • Loading branch information
noklam authored Mar 13, 2024
1 parent 9e883e6 commit 1f2adf1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/source/faq/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This is a growing set of technical FAQs. The [product FAQs on the Kedro website]
* [How can I debug a Kedro project in a Jupyter notebook](../notebooks_and_ipython/kedro_and_notebooks.md#debugging-a-kedro-project-within-a-notebook)?
* [How do I connect a Kedro project kernel to other Jupyter clients like JupyterLab](../notebooks_and_ipython/kedro_and_notebooks.md#ipython-jupyterlab-and-other-jupyter-clients)?
* [How can I use the Kedro IPython extension in a notebook where launching a new kernel is not an option](../notebooks_and_ipython/kedro_and_notebooks.md#loading-the-project-with-the-kedroipython-extension)?
* [How to fix Line magic function `%reload_kedro` not found?](../notebooks_and_ipython/kedro_and_notebooks.md#loading-the-project-with-kedro-jupyter-notebook)

## Kedro project development

Expand Down
17 changes: 13 additions & 4 deletions docs/source/notebooks_and_ipython/kedro_and_notebooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ The `kedro jupyter notebook` command launches a notebook with a customised kerne
* `pipelines` (type `dict[str, Pipeline]`): Pipelines defined in your [pipeline registry](../nodes_and_pipelines/run_a_pipeline.md#run-a-pipeline-by-name)
* `session` (type {py:class}`~kedro.framework.session.session.KedroSession`): [Kedro session](../kedro_project_setup/session.md) that orchestrates a pipeline run

In addtion, it also runs `%load_ext kedro.ipython` automatically when you launch the notebook.

``` {note}
If the Kedro variables are not available within your Jupyter notebook, you could have a malformed configuration file or missing dependencies. The full error message is shown on the terminal used to launch `kedro jupyter notebook`.
If the Kedro variables are not available within your Jupyter notebook, you could have a malformed configuration file or missing dependencies. The full error message is shown on the terminal used to launch `kedro jupyter notebook` or run `%load_ext kedro.ipython` in a notebook cell.
```

## Loading the project with the `kedro.ipython` extension
Expand Down Expand Up @@ -226,15 +228,22 @@ For more details, run `%reload_kedro?`.
``` {note}
This is still an experimental feature and is currently only available for Jupyter Notebook (>7.0), Jupyter Lab, IPython, and VSCode Notebook. If you encounter unexpected behaviour or would like to suggest feature enhancements, add it under [this github issue](https://github.com/kedro-org/kedro/issues/3580).
```
You can load the contents of a node in your project into a series of cells using the `%load_node` line magic. To use `%load_node`, the node you want to load needs to fulfil two requirements:
- The node needs to have a name
- The node's inputs need to be persisted

The [section about creating nodes with names](../nodes_and_pipelines/nodes.md#how-to-create-a-node) explains how to ensure your node has a name. By default, Kedro saves data in memory. To persist the data, you need to [declare the dataset in the Data Catalog](../tutorial/create_a_pipeline.md#preprocessed-data-registration).

``` {note}
The node name needs to be unique within the pipeline. In the absence of a user defined name, Kedro generates one using a combination of the function name, inputs and outputs.
```

You can load the contents of a node in your project into a series of cells using the `%load_node` line magic.
The line magic will load your node's inputs, imports, and body:

```ipython
%load_node <my-node-name>
```

Ensure you use the name of your node as defined in the pipeline, not the name of the node function. The line magic will load your node's inputs, imports, and body:

<details>
<summary>Click to see an example.</summary>

Expand Down

0 comments on commit 1f2adf1

Please sign in to comment.