Hi guys! I am trying to load kedro functionalities...
# questions
g
Hi guys! I am trying to load kedro functionalities in a
jupyter notebook
but it gives me the following error:
%load_ext kedro.ipython
Copy code
RuntimeError: Missing required keys ['project_version'] from 'pyproject.toml'.
Kedro was working fine for the last 2 weeks. I didn't do any update on
kedro
. In
requirements
I have
kedro~=0.18.6
In
Pipfile.lock
I have kedro
==0.18.4
In
project.toml
I have:
Copy code
[tool.kedro]
package_name = "cashflow_ml"
project_name = "cashflow-ml"
kedro_init_version = "0.18.6"

[tool.isort]
profile = "black"

[tool.pytest.ini_options]
addopts = """
--cov-report term-missing \
--cov src/cashflow_ml -ra"""

[tool.coverage.report]
fail_under = 0
show_missing = true
exclude_lines = ["pragma: no cover", "raise NotImplementedError"]
I tried to change the
kedro_init_version
to
0.18.4
but I still got the same error. Does someone have a clue on it?
j
hi @Guilherme Parreira! can you paste the full traceback?
possibly relevant PR: https://github.com/kedro-org/kedro/pull/2219 merged in 0.18.5
g
Copy code
%load_ext kedro.ipython

[05/24/23 09:13:49] INFO     Resolved project path as: /home/guilherme/cashflow-ml.                 __init__.py:132
                             To set a different path, run '%reload_kedro <project_root>'                           
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /tmp/ipykernel_7953/468069963.py:2 in <module>                                                   │
│                                                                                                  │
│ [Errno 2] No such file or directory: '/tmp/ipykernel_7953/468069963.py'                          │
│                                                                                                  │
│ /home/guilherme/.local/share/virtualenvs/cashflow-ml-D-P6NUn9/lib/python3.10/site-packages/IPyth │
│ on/core/interactiveshell.py:2417 in run_line_magic                                               │
│                                                                                                  │
│   2414 │   │   │   if getattr(fn, "needs_local_scope", False):                                   │
│   2415 │   │   │   │   kwargs['local_ns'] = self.get_local_scope(stack_depth)                    │
│   2416 │   │   │   with self.builtin_trap:                                                       │
│ ❱ 2417 │   │   │   │   result = fn(*args, **kwargs)                                              │
│   2418 │   │   │                                                                                 │
│   2419 │   │   │   # The code below prevents the output from being displayed                     │
│   2420 │   │   │   # when using magics with decodator @output_can_be_silenced                    │
│                                                                                                  │
│ /home/guilherme/.local/share/virtualenvs/cashflow-ml-D-P6NUn9/lib/python3.10/site-packages/IPyth │
│ on/core/magics/extension.py:33 in load_ext                                                       │
│                                                                                                  │
│   30 │   │   """Load an IPython extension by its module name."""                                 │
│   31 │   │   if not module_str:                                                                  │
│   32 │   │   │   raise UsageError('Missing module name.')                                        │
│ ❱ 33 │   │   res = self.shell.extension_manager.load_extension(module_str)                       │
│   34 │   │                                                                                       │
│   35 │   │   if res == 'already loaded':                                                         │
│   36 │   │   │   print("The %s extension is already loaded. To reload it, use:" % module_str)    │
│                                                                                                  │
│ /home/guilherme/.local/share/virtualenvs/cashflow-ml-D-P6NUn9/lib/python3.10/site-packages/IPyth │
│ on/core/extensions.py:76 in load_extension                                                       │
│                                                                                                  │
│    73 │   │   function, or None if it succeeded.                                                 │
│    74 │   │   """                                                                                │
│    75 │   │   try:                                                                               │
│ ❱  76 │   │   │   return self._load_extension(module_str)                                        │
│    77 │   │   except ModuleNotFoundError:                                                        │
│    78 │   │   │   if module_str in BUILTINS_EXTS:                                                │
│    79 │   │   │   │   BUILTINS_EXTS[module_str] = True                                           │
│                                                                                                  │
│ /home/guilherme/.local/share/virtualenvs/cashflow-ml-D-P6NUn9/lib/python3.10/site-packages/IPyth │
│ on/core/extensions.py:93 in _load_extension                                                      │
│                                                                                                  │
│    90 │   │   │   if module_str not in sys.modules:                                              │
│    91 │   │   │   │   mod = import_module(module_str)                                            │
│    92 │   │   │   mod = sys.modules[module_str]                                                  │
│ ❱  93 │   │   │   if self._call_load_ipython_extension(mod):                                     │
│    94 │   │   │   │   self.loaded.add(module_str)                                                │
│    95 │   │   │   else:                                                                          │
│    96 │   │   │   │   return "no load function"                                                  │
│                                                                                                  │
│ /home/guilherme/.local/share/virtualenvs/cashflow-ml-D-P6NUn9/lib/python3.10/site-packages/IPyth │
│ on/core/extensions.py:145 in _call_load_ipython_extension                                        │
│                                                                                                  │
│   142 │                                                                                          │
│   143 │   def _call_load_ipython_extension(self, mod):                                           │
│   144 │   │   if hasattr(mod, 'load_ipython_extension'):                                         │
│ ❱ 145 │   │   │   mod.load_ipython_extension(self.shell)                                         │
│   146 │   │   │   return True                                                                    │
│   147 │                                                                                          │
│   148 │   def _call_unload_ipython_extension(self, mod):                                         │
│                                                                                                  │
│ /home/guilherme/.local/share/virtualenvs/cashflow-ml-D-P6NUn9/lib/python3.10/site-packages/kedro │
│ /ipython/__init__.py:40 in load_ipython_extension                                                │
│                                                                                                  │
│    37 │   │   return                                                                             │
│    38 │                                                                                          │
│    39 │   ipython.register_magic_function(magic_reload_kedro, magic_name="reload_kedro")         │
│ ❱  40 │   reload_kedro()                                                                         │
│    41                                                                                            │
│    42                                                                                            │
│    43 @needs_local_scope                                                                         │
│                                                                                                  │
│ /home/guilherme/.local/share/virtualenvs/cashflow-ml-D-P6NUn9/lib/python3.10/site-packages/kedro │
│ /ipython/__init__.py:82 in reload_kedro                                                          │
│                                                                                                  │
│    79 │                                                                                          │
│    80 │   project_path = _resolve_project_path(path, local_namespace)                            │
│    81 │                                                                                          │
│ ❱  82 │   metadata = bootstrap_project(project_path)                                             │
│    83 │   _remove_cached_modules(metadata.package_name)                                          │
│    84 │   configure_project(metadata.package_name)                                               │
│    85                                                                                            │
│                                                                                                  │
│ /home/guilherme/.local/share/virtualenvs/cashflow-ml-D-P6NUn9/lib/python3.10/site-packages/kedro │
│ /framework/startup.py:153 in bootstrap_project                                                   │
│                                                                                                  │
│   150 │   """Run setup required at the beginning of the workflow                                 │
│   151 │   when running in project mode, and return project metadata.                             │
│   152 │   """                                                                                    │
│ ❱ 153 │   metadata = _get_project_metadata(project_path)                                         │
│   154 │   _add_src_to_path(metadata.source_dir, project_path)                                    │
│   155 │   configure_project(metadata.package_name)                                               │
│   156 │   return metadata                                                                        │
│                                                                                                  │
│ /home/guilherme/.local/share/virtualenvs/cashflow-ml-D-P6NUn9/lib/python3.10/site-packages/kedro │
│ /framework/startup.py:92 in _get_project_metadata                                                │
│                                                                                                  │
│    89 │   mandatory_keys = ["package_name", "project_name", "project_version"]                   │
│    90 │   missing_keys = [key for key in mandatory_keys if key not in metadata_dict]             │
│    91 │   if missing_keys:                                                                       │
│ ❱  92 │   │   raise RuntimeError(f"Missing required keys {missing_keys} from '{_PYPROJECT}'.")   │
│    93 │                                                                                          │
│    94 │   # check the match for major and minor version (skip patch version)                     │
│    95 │   if metadata_dict["project_version"].split(".")[:2] != kedro_version.split(".")[:2]:    │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
RuntimeError: Missing required keys ['project_version'] from 'pyproject.toml'.
j
that code is for Kedro 0.18.4, but I see you created the project with Kedro 0.18.6, so you have a version mismatch
you can either declare Kedro 0.18.6 in Pipfile.lock, or add
project_version = "0.18.4"
(and modify
kedro_init_version
too). I'd recommend the latter