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.

TypeError: unhashable type: 'list'

See original GitHub issue

Description

When using list as one of the inputs, I got this error

Context

I tried to pass a string and a list to the function, but I cannot. This will prevent me from passing any list as an argument to my function.

Steps to Reproduce

When I run this code

a = 'string'
b = [1,2,3]

def dummy_func(a, b):
   return 'hello'

data_catalog = DataCatalog({'events': MemoryDataSet()})
dummy_func_node =  node(func=dummy_func, inputs=[a, b], outputs='events')
pipeline = Pipeline([dummy_func_node])
runner = SequentialRunner()
print(runner.run(pipeline, data_catalog))

I got

Traceback (most recent call last):
  File "src/get_events.py", line 66, in main
    dummy_func_node =  node(func=dummy_func, inputs=[a, b], outputs='events')
  File "/home/khuyentran/anaconda3/envs/scraping/lib/python3.8/site-packages/kedro/pipeline/node.py", line 665, in node
    return Node(
  File "/home/khuyentran/anaconda3/envs/scraping/lib/python3.8/site-packages/kedro/pipeline/node.py", line 133, in __init__
    self._validate_inputs_dif_than_outputs()
  File "/home/khuyentran/anaconda3/envs/scraping/lib/python3.8/site-packages/kedro/pipeline/node.py", line 570, in _validate_inputs_dif_than_outputs
    common_in_out = set(self.inputs).intersection(set(self.outputs))
TypeError: unhashable type: 'list'

I looked at the source code, and it seems like this error is due to the fact that there will be an error if you take a set of a list of list in common_in_out = set(self.inputs).intersection(set(self.outputs)). I wonder if kedro provides any option when one of the inputs is a list?

Your Environment

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

  • Kedro version used: 0.16.4
  • Python version used: Python 3.8.3
  • Operating system and version: Ubuntu 19.10

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
khuyentran1401commented, Feb 17, 2021

Got it! I think this one provides a good example of how to create modular pipelines. You might want to fix the broken image on this website. This should give me enough information to experiment more with Kedro. Thank you for the help!

1reaction
limdautocommented, Feb 16, 2021

@mzjp2 is correct. The mental model here is: the node(...) function receives a collection of dataset names as inputs and outputs, not the values themselves.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Handle Unhashable Type List Exceptions in Python
The Python TypeError: unhashable type: 'list' usually means that a list is being used as a hash argument. This error occurs when trying...
Read more >
Python: TypeError: unhashable type: 'list' - Net-Informations.Com
TypeError : unhashable type: 'list' usually means that you are trying to use a list as an hash argument. This means that when...
Read more >
How to overcome TypeError: unhashable type: 'list' [duplicate]
The TypeError is happening because k is a list, since it is created using a slice from ...
Read more >
Python TypeError: unhashable type: 'list' Solution
The “TypeError: unhashable type: 'list'” error is raised when you try to assign a list as a key in a dictionary. To solve...
Read more >
TypeError: unhashable type: 'list' - STechies
This error occurs when you try to use a list as key in the dictionary or set. As you know 'list' is an...
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