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])
| 140 | |
| 141 | @DeveloperAPI |
| 142 | def 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…