MCPcopy
hub / github.com/ray-project/ray / from_blocks

Function from_blocks

python/ray/data/read_api.py:142–162  ·  view source on GitHub ↗

Create a :class:`~ray.data.Dataset` from a list of blocks. This method is primarily used for testing. Unlike other methods like :func:`~ray.data.from_pandas` and :func:`~ray.data.from_arrow`, this method gaurentees that it won't modify the number of blocks. Args: blocks: Li

(blocks: List[Block])

Source from the content-addressed store, hash-verified

140
141@DeveloperAPI
142def from_blocks(blocks: List[Block]):
143 """Create a :class:`~ray.data.Dataset` from a list of blocks.
144
145 This method is primarily used for testing. Unlike other methods like
146 :func:`~ray.data.from_pandas` and :func:`~ray.data.from_arrow`, this method
147 gaurentees that it won't modify the number of blocks.
148
149 Args:
150 blocks: List of blocks to create the dataset from.
151
152 Returns:
153 A :class:`~ray.data.Dataset` holding the blocks.
154 """
155 block_refs = [ray.put(block) for block in blocks]
156 meta_with_schema = [BlockMetadataWithSchema.from_block(block) for block in blocks]
157
158 from_blocks_op = FromBlocks(block_refs, meta_with_schema)
159 stats = DatasetStats(metadata={"FromBlocks": meta_with_schema}, parent=None)
160 context = DataContext.get_current().copy()
161 logical_plan = LogicalPlan(from_blocks_op, context)
162 return MaterializedDataset(logical_plan, context, stats)
163
164
165@PublicAPI

Callers

nothing calls this directly

Calls 8

FromBlocksClass · 0.90
DatasetStatsClass · 0.90
LogicalPlanClass · 0.90
MaterializedDatasetClass · 0.90
from_blockMethod · 0.80
putMethod · 0.65
copyMethod · 0.65
get_currentMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…