diff --git a/RELEASE.md b/RELEASE.md index de34aeca18..abc4e324c0 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -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 diff --git a/docs/source/kedro_project_setup/session.md b/docs/source/kedro_project_setup/session.md index 5c498dde61..1275643c51 100644 --- a/docs/source/kedro_project_setup/session.md +++ b/docs/source/kedro_project_setup/session.md @@ -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. diff --git a/docs/source/meta/images/kedro-session-creation.png b/docs/source/meta/images/kedro-session-creation.png new file mode 100644 index 0000000000..a2e62c8f31 Binary files /dev/null and b/docs/source/meta/images/kedro-session-creation.png differ