How can I run a project inside the IDE?

Hello,

I want to understand better how the different parts of Kedro work, and in order to do that, I’d like to run a project from the IDE and debug it. I don’t know how to do it. I have tried using the run() method in cli.py, the run.py module, and nothing works. I always get some error with the imports… It’s an almost blank project, with three very basic nodes. If I do “kedro run” from command line, the run works.

I am sorry for asking so basic questions…

Hi @Jaime_Arboleda_Casti,

check out the guides below. I have found them quite useful for debugging.

https://kedro.readthedocs.io/en/latest/09_development/02_set_up_pycharm.html#debugging
https://kedro.readthedocs.io/en/latest/09_development/01_set_up_vscode.html#debugging

1 Like

Thanks a lot, Sebastian! I’ll take a look and try to configure PyCharm for debugging.

However, I’d like to run a project using my own code, and I’m a little bit frustrated for not achieving it. This is what happens:

  1. I have Kedro 0.17.0 version.
  2. I do “kedro new” and create a project called “example”.
  3. Inside of “pipelines” folder, I add a new folder called “pipeline”, with an init.py, nodes.py and pipeline.py.
  4. I code a super basic pipeline, with only one node, without input and an output which is a static csv which is referenced in the catalog (so I can check if the node has run succesfully).
  5. When I do all that, if I write “kedro run” in the command line, the pipeline runs succesfully.
  6. However, I cannot reproduce it running the run.py inside my IDE (which is still Spyder, although I will change to PyCharm).

The code in run.py is the following:

“”“Application entry point.”""
from pathlib import Path

from kedro.framework.session import KedroSession

def run_package():
# Entry point for running a Kedro project packaged with kedro package
# using python -m <project_package>.run command.
package_name = Path(file).resolve().parent.name
with KedroSession.create(package_name) as session:
session.run()

if name == “main”:
run_package()

The error is “ModuleNotFoundError: No module named ‘example’”. I have tried changing the path, with os.chdir and other things but I wasn’t lucky enough. I will appreciate a lot some help because I don’t want to run my pipelines only from the command line, if possible. Thanks!

1 Like

You might need to add your src/ folder to your PYTHONPATH in the PyCharm.

As described in the linked documentation above, you can do that (or achieve a similar effect) in PyCharm by selecting your src/ folder and marking it as “Sources root”.

1 Like

Ok, thanks a lot. However, it is indeed very confortable to run and debug a project with a configured PyCharm so I think that I might not need it…

1 Like