[Bug] Running sync examples from documentation result in TypeError: FromIterable() takes no arguments.
Paperone80 opened this issue · comments
Describe the bug
Running your sync examples results in TypeError
Minimal code to reproduce
Small snippet that contains a minimal amount of code.
Source: https://cgarciae.github.io/pypeln/api/sync/Overview/
import pypeln as pl
import time
from random import random
def slow_integer_pair(x):
time.sleep(random()) # <= some slow computation
if x == 0:
yield x
else:
yield x
yield -x
data = range(10) # [0, 1, 2, ..., 9]
stage = pl.sync.flat_map(slow_integer_pair, data, workers=3, maxsize=4)
list(stage) # [0, 1, -1, 2, -2, ..., 9, -9]
Expected behavior
No TypeError
Library Info
Please provide os info and elegy version.
Ubuntu: 16.04
Python: 3.9
Pypeln: 0.4.9
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [1], in <cell line: 15>()
12 yield -x
14 data = range(10) # [0, 1, 2, ..., 9]
---> 15 stage = pl.sync.flat_map(slow_integer_pair, data, workers=3, maxsize=4)
17 list(stage)
File /opt/intelpython3/envs/python3.9_env_tf2_od/lib/python3.9/site-packages/pypeln/sync/api/flat_map.py:126, in flat_map(f, stage, workers, maxsize, timeout, on_start, on_done)
113 if isinstance(stage, pypeln_utils.Undefined):
114 return pypeln_utils.Partial(
115 lambda stage: flat_map(
116 f,
(...)
123 )
124 )
--> 126 stage_ = to_stage(stage, maxsize=maxsize)
128 return Stage(
129 process_fn=FlatMap(f),
130 timeout=timeout,
(...)
134 f_args=pypeln_utils.function_args(f),
135 )
File /opt/intelpython3/envs/python3.9_env_tf2_od/lib/python3.9/site-packages/pypeln/sync/api/to_stage.py:12, in to_stage(obj, maxsize)
10 return obj
11 else:
---> 12 return from_iterable(obj, maxsize=maxsize)
File /opt/intelpython3/envs/python3.9_env_tf2_od/lib/python3.9/site-packages/pypeln/sync/api/from_iterable.py:62, in from_iterable(iterable, use_thread, maxsize)
58 if isinstance(iterable, pypeln_utils.Undefined):
59 return pypeln_utils.Partial(lambda iterable: from_iterable(iterable))
61 return Stage(
---> 62 process_fn=FromIterable(iterable, maxsize=maxsize),
63 timeout=0,
64 dependencies=[],
65 on_start=None,
66 on_done=None,
67 f_args=[],
68 )
TypeError: FromIterable() takes no arguments