python/ray/data/read_api.py
def from_items(items: List[Any], *, parallelism: int = 200) -> Dataset[Any]:
    """Create a dataset from a list of local Python objects.

    Examples:
        >>> import ray
        >>> ray.data.from_items([1, 2, 3, 4, 5]) # doctest: +SKIP

    Args:
        items: List of local Python objects.
        parallelism: The amount of parallelism to use for the dataset.
            Parallelism may be limited by the number of items.

    Returns:
        Dataset holding the items.
    """
    block_size = max(1, len(items) // parallelism)

    blocks: List[ObjectRef[Block]] = []
    metadata: List[BlockMetadata] = []
    i = 0
    while i < len(items):
        stats = BlockExecStats.builder()
        builder = DelegatingBlockBuilder()
        for item in items[i : i + block_size]:
            builder.add(item)
        block = builder.build()
        blocks.append(ray.put(block))
        metadata.append(
            BlockAccessor.for_block(block).get_metadata(
                input_files=None, exec_stats=stats.build()
            )
        )
        i += block_size

    return Dataset(
        ExecutionPlan(
            BlockList(blocks, metadata),
            DatasetStats(stages={"from_items": metadata}, parent=None),
        ),
        0,
        False,
    )
Create a dataset from a list of local Python objects.

    Examples:
        >>> import ray
        >>> ray.data.from_items([1, 2, 3, 4, 5]) # doctest: +SKIP

    Args:
        items: List of local Python objects.
        parallelism: The amount of parallelism to use for the dataset.
            Parallelism may be limited by the number of items.

    Returns:
        Dataset holding the items.
    
Create a dataset from a list of local Python objects.
Create a dataset from a list of local Python objects .
def from_items(items: List[Any], *, parallelism: int = 200) -> Dataset[Any]:
    block_size = max(1, len(items) // parallelism)
    blocks: List[ObjectRef[Block]] = []
    metadata: List[BlockMetadata] = []
    i = 0
    while i < len(items):
        stats = BlockExecStats.builder()
        builder = DelegatingBlockBuilder()
        for item in items[i : i + block_size]:
            builder.add(item)
        block = builder.build()
        blocks.append(ray.put(block))
        metadata.append(
            BlockAccessor.for_block(block).get_metadata(
                input_files=None, exec_stats=stats.build()
            )
        )
        i += block_size
    return Dataset(
        ExecutionPlan(
            BlockList(blocks, metadata),
            DatasetStats(stages={"from_items": metadata}, parent=None),
        ),
        0,
        False,
    )
def from_items ( items : List [ Any ] , * , parallelism : int = 200 ) -> Dataset [ Any ] : block_size = max ( 1 , len ( items ) // parallelism ) blocks : List [ ObjectRef [ Block ] ] = [ ] metadata : List [ BlockMetadata ] = [ ] i = 0 while i < len ( items ) : stats = BlockExecStats . builder ( ) builder = DelegatingBlockBuilder ( ) for item in items [ i : i + block_size ] : builder . add ( item ) block = builder . build ( ) blocks . append ( ray . put ( block ) ) metadata . append ( BlockAccessor . for_block ( block ) . get_metadata ( input_files = None , exec_stats = stats . build ( ) ) ) i += block_size return Dataset ( ExecutionPlan ( BlockList ( blocks , metadata ) , DatasetStats ( stages = { "from_items" : metadata } , parent = None ) , ) , 0 , False , )
Create a dataset from a list of local Python objects.
Create a dataset from a list of local Python objects .
"""Create a dataset from a list of local Python objects.

    Examples:
        >>> import ray
        >>> ray.data.from_items([1, 2, 3, 4, 5]) # doctest: +SKIP

    Args:
        items: List of local Python objects.
        parallelism: The amount of parallelism to use for the dataset.
            Parallelism may be limited by the number of items.

    Returns:
        Dataset holding the items.
    """
Dataset holding the items.
Dataset holding the items .
items
List[Any]
List of local Python objects.
List of local Python objects .
parallelism
int
The amount of parallelism to use for the dataset.
Parallelism may be limited by the number of items.
The amount of parallelism to use for the dataset . Parallelism may be limited by the number of items .
examples
None