Hi, I'm wondering about the structure of the proje...
# questions
j
Hi, I'm wondering about the structure of the project. According to https://docs.kedro.org/en/stable/development/automated_testing.html#set-up-automated-testing-with-pytest the test folder should be under /src. However, in the starter example (https://github.com/kedro-org/kedro-starters/tree/main/spaceflights-pandas/%7B%7B%20cookiecutter.repo_name%20%7D%7D (and while running
kedro new --name=<your-project-name> --example=yes
) it's created separately on the same level as /src. Is this a bug or a feature?
btw I'm really waiting for https://github.com/kedro-org/kedro/issues/1271, could the internal docs become public some day?
d
I believe test should be outside
src
, and this is a known issue that needs to be updated.
👍 1
> btw I'm really waiting for https://github.com/kedro-org/kedro/issues/1271, could the internal docs become public some day? > This issue is being worked on now!
❤️ 1
j
Thanks! Is there a discussion where I could learn more on why it should be kept seperate?
d
Let me find a link; in short, purpose or src layout is to isolate code from other things.
n
@Julian Nowak Would you mind leave a comment on the issue itself? It helps a lot for our priority.
though I know that it's WIP and there are tickets this sprint for extracting that internal document to the public documentation, stay tuned :) Cc @Ahdra Merali
j
@Nok Lam Chan sure, on this one: https://github.com/kedro-org/kedro/issues/1271
?
👍🏼 1
Added! And where I could raise the issue of inconsistency between docs and the sample project structure?
thankyou 1
n
that issue exist already
d
j
I have a question then, my custom dataset that I created imports some function from:
Copy code
from {project}.pipelines.common_methods import _to_numeric
when I reference the dataset in its test:
Copy code
from src.{project}.datasets.my_dataset import MyDataset
(now I have to add this
src.
, right?) and run
pytest
I get the error
Copy code
src\{project}\datasets\MyDataset.py:13: in <module>
    from {project}.pipelines.common_methods import _to_numeric
E   ModuleNotFoundError: No module named '{project}'
Should I add my project to pytonpath in some other way that it is done by default?
d
Yeah, you shouldn't import
from src
https://stackoverflow.com/a/50156706 this is a nice solution; actually wasn't aware of it previously, but should work
j
The first method didn't work for me, but installing it with
pip install .
does
t
I suggest you to install your project in editable mode:
pip install -e .
👍 2
j
@Takieddine Kadiri thanks!
👍 1
t
By going into the
pip install
approach you're not relying on kedro nor on pytest for adding your packages that live under
src
to the sys path, you could then import your package from whatever module that live inside your python env. You're however relying on Kedro's template that preconfigure the
pyproject.toml
to play well with the src layout.
j
I hope best practices for this will be included in the documentation as well 😄