Skip to content

Commit

Permalink
Make source_dir discoverable for non-src project (kedro-org#3458)
Browse files Browse the repository at this point in the history
* Update docs

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

* Added source_dir into pyproject.toml template

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

* add faq

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

* update choice of word base on vale suggestion

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

* add example_pipeline

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

---------

Signed-off-by: Nok <[email protected]>
Signed-off-by: Nok Lam Chan <[email protected]>
  • Loading branch information
noklam committed Jan 8, 2024
1 parent 077be82 commit 9831e12
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Removed example pipeline requirements when examples are not selected in `tools`.
* Allowed modern versions of JupyterLab and Jupyter Notebooks.
* Removed setuptools dependency
* Added `source_dir` explicitly in `pyproject.toml` for non-src layout project.

## Breaking changes to the API
* Added logging about not using async mode in `SequentiallRunner` and `ParallelRunner`.
Expand Down
1 change: 1 addition & 0 deletions docs/source/faq/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ This is a growing set of technical FAQs. The [product FAQs on the Kedro website]
* [How to use global variables with the `OmegaConfigLoader`](../configuration/advanced_configuration.md#how-to-use-global-variables-with-the-omegaconfigloader)?
* [How do I use resolvers in the `OmegaConfigLoader`](../configuration/advanced_configuration.md#how-to-use-resolvers-in-the-omegaconfigloader)?
* [How do I load credentials through environment variables](../configuration/advanced_configuration.md#how-to-load-credentials-through-environment-variables)?
* [How do I use Kedro with different project structure?](../kedro_project_setup/settings.md#use-kedro-without-the-src-folder)


## Nodes and pipelines
Expand Down
11 changes: 11 additions & 0 deletions docs/source/kedro_project_setup/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Every Kedro project comes with a default pre-populated `pyproject.toml` file in
package_name = "package_name"
project_name = "project_name"
kedro_init_version = "kedro_version"
tools = ""
example_pipeline = "False"
source_dir = "src"
```

The `package_name` should be a [valid Python package name](https://peps.python.org/pep-0423/) and the `project_name` should be a human-readable name. They are both mandatory keys for your project.
Expand All @@ -40,3 +43,11 @@ this value should also be updated.
You can also use `pyproject.toml` to specify settings for functionalities such as [micro-packaging](../nodes_and_pipelines/micro_packaging.md).
You can also store the settings for the other tools you've used in your project, such as [`pytest` for automated testing](../development/automated_testing.md).
Consult the respective documentation for the tools you have used to check how you can configure the settings with the `pyproject.toml` file for your project.

### Use Kedro without the `src` folder
Kedro uses the `src` layout by default. It is possible to change this, for example, to use a [flat layout](https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/#src-layout-vs-flat-layout), you can change the `pyproject.toml` as follow.

```diff
+++ source_dir = ""
--- source_dir = "src"
```
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ project_name = "{{ cookiecutter.project_name }}"
kedro_init_version = "{{ cookiecutter.kedro_version }}"
tools = {{ cookiecutter.tools | default('') | string | replace('\"', '\\\"') }}
example_pipeline = "{{ cookiecutter.example_pipeline }}"
source_dir = "src"


[tool.pytest.ini_options]
addopts = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ project_name = "{{ cookiecutter.project_name }}"
kedro_init_version = "{{ cookiecutter.kedro_version }}"
tools = {{ cookiecutter.tools | default('') | string | replace('\"', '\\\"') }}
example_pipeline = "{{ cookiecutter.example_pipeline }}"
source_dir = "src"

[tool.pytest.ini_options]
addopts = """
Expand Down

0 comments on commit 9831e12

Please sign in to comment.