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.

"Hello world" example from the docs doesn't work on Kedro 0.18

See original GitHub issue

Description

Following “Hello World” example from the docs on Kedro 0.18.0 fails with missing 1 required positional argument: 'hook_manager' for runner.run()

Context

Completing quickstart tutorial

Steps to Reproduce

  1. pip install kedro==0.18.0
  2. Follow https://kedro.readthedocs.io/en/0.18.0/get_started/hello_kedro.html#hello-kedro

Expected Result

This is how it behaves on 0.17.7:

$ python hello_kedro.py 
/opt/conda/envs/kedro-new/lib/python3.8/site-packages/kedro/io/data_catalog.py:189: DeprecationWarning: The transformer API will be deprecated in Kedro 0.18.0.Please use Dataset Hooks to customise the load and save methods.For more information, please visithttps://kedro.readthedocs.io/en/stable/07_extend_kedro/02_hooks.html
  warnings.warn(
{'my_message': 'Hello Kedro!'}

Actual Result

On 0.18.0:

$ python hello_kedro.py 
Traceback (most recent call last):
  File "hello_kedro.py", line 32, in <module>
    print(runner.run(greeting_pipeline, data_catalog))
TypeError: run() missing 1 required positional argument: 'hook_manager'

Your Environment

  • Kedro version used (pip show kedro or kedro -V): 0.18.0
  • Python version used (python -V): 3.8.13
  • Operating system and version: Ubuntu 21.10

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:3
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
sebaxtiancommented, Apr 7, 2022

Hi @szczeles, I tried this on the hello kedro example in order to solve the issue, I’m not sure that is the right solution but its works for me

"""Contents of hello_kedro.py"""
from kedro.io import DataCatalog, MemoryDataSet
from kedro.pipeline import node, pipeline
from kedro.runner import SequentialRunner
from kedro.framework.session import KedroSession


# Prepare a data catalog
data_catalog = DataCatalog({"my_salutation": MemoryDataSet()})

# Prepare first node
def return_greeting():
    return "Hello"


return_greeting_node = node(return_greeting, inputs=None, outputs="my_salutation")

# Prepare second node
def join_statements(greeting):
    return f"{greeting} Kedro!"


join_statements_node = node(
    join_statements, inputs="my_salutation", outputs="my_message"
)

# Assemble nodes into a pipeline
greeting_pipeline = pipeline([return_greeting_node, join_statements_node])

# Create a runner to run the pipeline
runner = SequentialRunner()

# HERE: this section --->
# Added the PluginManager hook_manager argument to KedroContext and the Runner.run() method,
# which will be provided by the KedroSession.
hook_manager = KedroSession('kedro-hello-world')._hook_manager
# <--- HERE: this section 


# Run the pipeline
print(runner.run(greeting_pipeline, data_catalog, hook_manager))

Please read the Breaking changes to the API section on the release https://github.com/kedro-org/kedro/releases/tag/0.18.0

I added this to the hello world example code:

# Added the PluginManager hook_manager argument to KedroContext and the Runner.run() method,
# which will be provided by the KedroSession.
hook_manager = KedroSession('kedro-hello-world')._hook_manager

Please, give me a feedback, thanks

2reactions
AntonyMilneQBcommented, Apr 11, 2022

Just for the purposes of getting a running tutorial, I’d recommend using _create_hook_manager (which is what’s called inside KedroSession) as the least bad option:

from kedro.framework.session.session import _create_hook_manager
print(runner.run(greeting_pipeline, data_catalog, _create_hook_manager())

(Solution courtesy of @noklam)

The minor advantage of this compared to what @sebaxtian suggests is that you don’t need to create a KedroSession.

However, this is obviously a horrible solution and we will figure out a better one. Basically calling runner.run is a very unusual thing to do - we only do it in this Hello world tutorial, and in general you would programatically call a kedro run using session.run like this. When we made the changes to 0.18 we didn’t realise that this would make calling runner.run in the Hello world tutorial so much more awkward and ugly, sorry!

Read more comments on GitHub >

github_iconTop Results From Across the Web

A “Hello World” example — Kedro 0.18.1 documentation
A node is a Kedro concept. It is a wrapper for a Python function that names the inputs and outputs of that function....
Read more >
A “Hello World” example — Kedro 0.18.3 documentation
A node is a Kedro concept. It is a wrapper for a Python function that names the inputs and outputs of that function....
Read more >
Kedro concepts — Kedro 0.18.4 documentation - Read the Docs
A pipeline organises the dependencies and execution order of a collection of nodes and connects inputs and outputs while keeping your code modular....
Read more >
Kedro starters — Kedro 0.18.3 documentation
Kedro starters are used to create projects that contain code to run as-is, or to adapt and extend. They provide pre-defined example code...
Read more >
Set up the spaceflights project — Kedro 0.18.0 documentation
Install dependencies. Configure the project. Create a new project¶. Navigate to your chosen working directory and run the following to create ...
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