pl.sync.from_iterable

Creates a stage from an iterable.

Parameters:

Name Type Description Default
iterable Union[Iterable[~T], pypeln.utils.Undefined]

A source Iterable.

<pypeln.utils.Undefined object at 0x7f27e00aaaf0>
use_thread bool

This parameter is not used and only kept for API compatibility with the other modules.

True

Returns:

Type Description
Union[pypeln.sync.stage.Stage[~T], pypeln.utils.Partial[pypeln.sync.stage.Stage[~T]]]

Returns a Stage if the iterable parameters is given, else it returns a Partial.

Source code in pypeln/sync/api/from_iterable.py
def from_iterable(
    iterable: tp.Union[tp.Iterable[T], pypeln_utils.Undefined] = pypeln_utils.UNDEFINED,
    use_thread: bool = True,
    maxsize: int = 0,
) -> tp.Union[Stage[T], pypeln_utils.Partial[Stage[T]]]:
    """
    Creates a stage from an iterable.

    Arguments:
        iterable: A source Iterable.
        use_thread: This parameter is not used and only kept for API compatibility with the other modules.

    Returns:
        Returns a `Stage` if the `iterable` parameters is given, else it returns a `Partial`.
    """

    if isinstance(iterable, pypeln_utils.Undefined):
        return pypeln_utils.Partial(lambda iterable: from_iterable(iterable))

    return Stage(
        process_fn=FromIterable(iterable, maxsize=maxsize),
        timeout=0,
        dependencies=[],
        on_start=None,
        on_done=None,
        f_args=[],
    )