I have just started really diving in and playing with the latest version of kedro (0.17.0) and have really been enjoying the composability of the different pieces. Today I was playing with the KedroSession.
I discovered that you can easily load up your project from any directory with a simple function. If you have data stored locally the path will still be relative to the project.
# Added to my __init__.py from kedro.framework.session import KedroSession from kedro.framework.project import configure_project def get_session(): cur_path = os.getcwd() os.chdir(Path(__file__).parents) configure_project(package_name) session = KedroSession.create(Path(__file__).resolve().parent.name) os.chdir(cur_path) return session
If I add this to my projects
__init__.py file I can now access all of its context from anywhere.
import my_proj session = my_proj.get_session() session.run() session.load_context().catalog session.load_context().pipelines
edit added configure step ahead of create_session