Skip to content

Commit

Permalink
Add flowchart to explains the difference of bootstrap_project and `…
Browse files Browse the repository at this point in the history
…configure_project` (#3470)

* add flowchart and ref link

Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>

* fix image link

Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>

---------

Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
  • Loading branch information
noklam authored Jan 9, 2024
1 parent bda3751 commit aefe378
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Added logging about not using async mode in `SequentiallRunner` and `ParallelRunner`.

## Documentation changes
* Added documentations about `bootstrap_project` and `configure_project`.

## Community contributions

Expand Down
29 changes: 28 additions & 1 deletion docs/source/kedro_project_setup/session.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,31 @@ You can provide the following optional arguments in `KedroSession.create()`:
- `save_on_close`: A boolean value to indicate whether or not to save the session to disk when it's closed
- `env`: Environment for the `KedroContext`
- `extra_params`: Optional dictionary containing extra project parameters
for the underlying `KedroContext`; if specified, this will update (and therefore take precedence over) parameters retrieved from the project configuration
for the underlying **`KedroContext`**; if specified, this will update (and therefore take precedence over) parameters retrieved from the project configuration

## `bootstrap_project` and `configure_project`
```{image} ../meta/images/kedro-session-creation.png
:alt: mermaid-General overview diagram for KedroSession creation
```

% Mermaid code, see https://github.com/kedro-org/kedro/wiki/Render-Mermaid-diagrams
% graph LR
% subgraph Kedro Startup Flowchart
% A[bootstrap_project] -->|Read pyproject.toml| B
% A -->|Add project root to sys.path| B[configure_project]
% C[Initialize KedroSession]
% B --> |Read settings.py| C
% B --> |Read pipeline_registry.py| C
% end

Both `bootstrap_project` and `configure_project` handle the setup of a Kedro project, but there are subtle differences: `bootstrap_project` is used for project mode, and `configure_project` is used for packaged mode.

Kedro's CLI runs the functions at startup as part of `kedro run` so in most cases you don't need to call these functions. If you want to [interact with a Kedro project programatically in an interactive session such as Notebook](../notebooks_and_ipython/kedro_and_notebooks.md#reload_kedro-line-magic), use `%reload_kedro` line magic with Jupyter or IPython. Only use these functions directly if none of these methods work.

### `bootstrap_project`

This function uses `configure_project`, and additionally reads metadata from `pyproject.toml` and adds the project root to `sys.path` so the project can be imported as a Python package. It is typically used to work directly with the source code of a Kedro project.

### `configure_project`

This function reads `settings.py` and `pipeline_registry.py` and registers the configuration before Kedro's run starts. If you have a packaged Kedro project, you only need to run `configure_project` before executing your pipeline.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit aefe378

Please sign in to comment.