question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[KED-1274] Kedro Jupyter Notebook Issue- context not loading / %reload_kedro throws error

See original GitHub issue

Description

Upon starting kedro jupyter notebook, and running %reload_kedro. I get the below error.

  • root - ERROR - Kedro’s ipython session startup script failed: Could not retrive ‘context_path’ from ‘.kedro.yml’ in /path/to/project/notebooks. If you have created your project with Kedro version <0.15.0, make sure to update your project template. See https://github.com/quantumblacklabs/kedro/blob/master/RELEASE.md for how to migrate your Kedro project.

context is also not loaded into the notebook.

I am using kedro 0.15.1 itself.

Context

I cannot read in the datasets/config parameters etc. into notebooks as context is also not loaded. Command line still works fine.

It’s a bit weird as it used to work fine for a long time, untill it didn’t. I did not update/even install any new packages. Infact when I faced this issue for the first time, one of my notebooks was running fine but when i opened a new one i started getting this issue.

Steps to Reproduce

I am not sure how this could be done, but:

  1. kedro jupyter notebook
  2. Open a notebook and run %reload_kedro. Or try running context. (context is not loaded)
FileNotFoundError                         Traceback (most recent call last)
~/anaconda3/envs/myenv/lib/python3.6/site-packages/kedro/context/context.py in load_context(project_path, **kwargs)
    397     try:
--> 398         with kedro_yaml.open("r") as kedro_yml:
    399 

~/anaconda3/envs/myenv/lib/python3.6/pathlib.py in open(self, mode, buffering, encoding, errors, newline)
   1182         return io.open(str(self), mode, buffering, encoding, errors, newline,
-> 1183                        opener=self._opener)
   1184 

~/anaconda3/envs/myenv/lib/python3.6/pathlib.py in _opener(self, name, flags, mode)
   1036         # A stub for the opener argument to built-in open()
-> 1037         return self._accessor.open(self, flags, mode)
   1038 

~/anaconda3/envs/myenv/lib/python3.6/pathlib.py in wrapped(pathobj, *args)
    386         def wrapped(pathobj, *args):
--> 387             return strfunc(str(pathobj), *args)
    388         return staticmethod(wrapped)

FileNotFoundError: [Errno 2] No such file or directory: '/home/path/to/repository/project_dir/notebooks/.kedro.yml'

During handling of the above exception, another exception occurred:

KedroContextError                         Traceback (most recent call last)
<ipython-input-1-4924b8705645> in <module>
      2 from datetime import datetime
      3 notebook_start = time.time()
----> 4 get_ipython().run_line_magic('reload_kedro', '')

~/anaconda3/envs/myenv/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2312                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2313             with self.builtin_trap:
-> 2314                 result = fn(*args, **kwargs)
   2315             return result
   2316 

~/path/to/repository/project_dir/.ipython/profile_default/startup/00-kedro-init.py in reload_kedro(project_path, line)
     28         startup_error = err
     29         logging.error("Kedro's ipython session startup script failed:\n%s", str(err))
---> 30         raise err
     31 
     32 

~/path/to/repository/project_dir/.ipython/profile_default/startup/00-kedro-init.py in reload_kedro(project_path, line)
     14         from kedro.context import load_context
     15 
---> 16         context = load_context(project_path)
     17 
     18         logging.info("** Kedro project {}".format(context.project_name))

~/anaconda3/envs/myenv/lib/python3.6/site-packages/kedro/context/context.py in load_context(project_path, **kwargs)
    404             "your project with Kedro version <0.15.0, make sure to update your project template. "
    405             "See https://github.com/quantumblacklabs/kedro/blob/master/RELEASE.md "
--> 406             "for how to migrate your Kedro project.".format(str(project_path))
    407         )
    408 

KedroContextError: Could not retrive 'context_path' from '.kedro.yml' in /home/path/to/repository/project_dir/notebooks. If you have created your project with Kedro version <0.15.0, make sure to update your project template. See https://github.com/quantumblacklabs/kedro/blob/master/RELEASE.md for how to migrate your Kedro project.
-- Separate them if you have more than one.

Your Environment

Include as many relevant details about the environment in which you experienced the bug:

  • Kedro version used (pip show kedro or kedro -V): kedro, version 0.15.1
  • Python version used (python -V): Python 3.6.9 :: Anaconda, Inc.
  • Operating system and version: Distributor ID: Ubuntu Description: Ubuntu 14.04.6 LTS Release: 14.04 Codename: trusty

ipython version: 7.9.0

jupyter notebook --version: 6.0.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
selfishharicommented, Dec 10, 2019

I figured this out.

Apparently, i had imported a node module wrongly in another one of my nodes. When kedro starts jupyter apparently this wrong import was preventing startup files to load context properly.

To understand this error, we must run kedro ipython in terminal. That will print the error from our modules. Fix that and everything will be fine.

The whole issue was because kedro jupyter notebook doesn’t print startup errors properly. Or is there something i havent understood??

[(https://github.com/ipython/ipython/issues/10068#issuecomment-263692621)]

0reactions
mzjp2commented, Jul 15, 2020

You need to update the project version attribute in your ProjectContext class in src/<proj>/run.py from 0.15.9 to 0.16 after making the changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[KED-1274] Kedro Jupyter Notebook Issue- context not ...
Upon starting kedro jupyter notebook, and running %reload_kedro. I get the below error. root - ERROR - Kedro's ipython session startup script ...
Read more >
Use Kedro with IPython and Jupyter Notebooks/Lab
The context variable allows you to interact with Kedro library components from within the Kedro Jupyter notebook. ../_images/jupyter_notebook_showing_context.
Read more >
kedro context and catalog missing from ipython session
Even not able to load context either. I am running the kedro environment from a Docker container. I am not sure where I...
Read more >
Two Tricks to Optimize your Kedro Jupyter Flow - YouTube
Data Engineering is a tough job, and it can be made tougher by complex, difficult to understand data pipelines. In this series, we...
Read more >
kedro Changelog - pyup.io
Fix lazy pipelines loading causes `get_current_session` to throw an error. ... Fix `%run_viz` line magic to display kedro viz inside Jupyter notebook, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found