Hi, How can I import some files for a node? I h...
# questions
a
Hi, How can I import some files for a node? I have a set of helper functions for my data science
node.py
and instead of having the helper functions within the same
node.py
, I want to store it in a separate
helper.py
in the same data science folder. I tried importing the functions from helper.py with
from .helper import funcHelp1, funcHelp2
but this makes the whole data science pipeline to be undiscoverable.
b
This looks like the right way to do this. Pipelines are not discovered if there is some kind of syntax or runtime error in the definition. Kedro auto-discovery makes this tricky to debug though because it fails behind the scenes. To see the error explicitly then, just import the pipeline manually in the
pipeline_registry.py
file. For example:
Copy code
from my_pipeline import create_pipeline

pipe = create_pipeline()
Do
kedro run
and you should see a helpful error. Then delete those debug lines of code once you fix it.
👍 2
a
Hey Afiq, it works unless there’s something wrong with the helper file, for example if imports for functions used by the helper functions are missing in
helper.py
?
b
A better long-term solution than the simply "quick fix/debug" above is to learn and use different linting and testing tools that will help you discover these errors quicker 🙂 A good place to start would be both
ruff
and
pytest
👍 2