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.

Flatten doesn't work with DaskStream

See original GitHub issue

This code:

from __future__ import division, print_function

from time import sleep
from streamz import Stream
from dask.distributed import Client

client = Client()

def callback(datas):
    print(':',datas)
    return datas

source = Stream().scatter()
stream = source.partition(5)
stream = stream.map(callback)
stream = stream.flatten()

stream.buffer(15).gather().sink(print)

for i in range(30):
    source.emit(i)

returns:

Traceback (most recent call last):
  File "test.py", line 21, in <module>
: (0, 1, 2, 3, 4)
    source.emit(i)
  File "/home/klinger/years/2014/projects/devel/streamz/streamz/core.py", line 332, in emit
    sync(self.loop, _)
  File "/home/klinger/years/2014/projects/devel/streamz/streamz/core.py", line 1277, in sync
    six.reraise(*error[0])
  File "/home/klinger/years/2014/projects/devel/streamz/streamz/core.py", line 1262, in f
    result[0] = yield future
  File "/home/klinger/rossum/local/lib/python2.7/site-packages/tornado/gen.py", line 1099, in run
    value = future.result()
  File "/home/klinger/rossum/local/lib/python2.7/site-packages/tornado/concurrent.py", line 260, in result
    raise_exc_info(self._exc_info)
  File "/home/klinger/rossum/local/lib/python2.7/site-packages/tornado/gen.py", line 315, in wrapper
    yielded = next(result)
  File "/home/klinger/years/2014/projects/devel/streamz/streamz/core.py", line 327, in _
    result = yield self._emit(x)
  File "/home/klinger/years/2014/projects/devel/streamz/streamz/core.py", line 298, in _emit
    r = downstream.update(x, who=self)
  File "/home/klinger/years/2014/projects/devel/streamz/streamz/core.py", line 734, in update
    return self._emit(tuple(result))
  File "/home/klinger/years/2014/projects/devel/streamz/streamz/core.py", line 298, in _emit
    r = downstream.update(x, who=self)
  File "/home/klinger/years/2014/projects/devel/streamz/streamz/dask.py", line 58, in update
    return self._emit(result)
  File "/home/klinger/years/2014/projects/devel/streamz/streamz/core.py", line 298, in _emit
    r = downstream.update(x, who=self)
  File "/home/klinger/years/2014/projects/devel/streamz/streamz/core.py", line 1020, in update
    for item in x:
TypeError: 'Future' object is not iterable

Without dask interface (removing scatter and gather), everything works well.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
bzamecnikcommented, Nov 14, 2018

Problems:

  • DaskStream is missing specific flatten(), so core Stream.flatten() is used. It produces core streams instead of dask streams.
  • Even if we attach flatten to DaskStream (same way as for partition), it may get different values:
    • tuple of Future of value - eg. from partition before it - it can process it well
    • Future of tuple of value - it cannot iterate over Future - we need to yield the future first
0reactions
NyakioMureithicommented, Jul 11, 2019

Thanks a lot this was very helpful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to use flatten layer? (it does not flatten arrays) #1525
hello, I'm playing with the MNIST dataset, and surprise: the flatten layer does not flatten array here an example: julia> using Flux ...
Read more >
python - np.ndarray.flatten does not flatten - Stack Overflow
Try using np.stack to flatten the object dtype layering. – hpaulj. May 17, 2018 at 18:15.
Read more >
Flatten an Array with NumPy flatten - Datagy
Why doesn't NumPy flatten work? The NumPy flatten method doesn't modify an array, but rather returns a copy of the array.
Read more >
Flatten Command doesn't work after update to AutoCAD for ...
Solved: Hello, I recently downloaded autocad2017.3 and the flatten command is not working. Please help john.vellek has edited your subject ...
Read more >
Flatten a NumPy array with ravel() and flatten() - nkmk note
You can flatten a NumPy array ndarray with the numpy.label() function, or the ravel() and ... Note that it doesn't work on Python...
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