ray.data.range#

ray.data.range(n: int, *, parallelism: int = -1, concurrency: int | None = None, override_num_blocks: int | None = None) Dataset[source]#

Creates a Dataset from a range of integers [0..n).

This function allows for easy creation of synthetic datasets for testing or benchmarking Ray Data.

Examples

>>> import ray
>>> ds = ray.data.range(10000)
>>> ds
Dataset(num_rows=10000, schema={id: int64})
>>> ds.map(lambda row: {"id": row["id"] * 2}).take(4)
[{'id': 0}, {'id': 2}, {'id': 4}, {'id': 6}]
Parameters:
  • n – The upper bound of the range of integers.

  • parallelism – This argument is deprecated. Use override_num_blocks argument.

  • concurrency – The maximum number of Ray tasks to run concurrently. Set this to control number of tasks to run concurrently. This doesn’t change the total number of tasks run or the total number of output blocks. By default, concurrency is dynamically decided based on the available resources.

  • override_num_blocks – Override the number of output blocks from all read tasks. By default, the number of output blocks is dynamically decided based on input data size and available resources. You shouldn’t manually set this value in most cases.

Returns:

A Dataset producing the integers from the range 0 to n.

See also

range_tensor()

Call this method for creating synthetic datasets of tensor data.