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

Function test_random_block_order

python/ray/data/tests/test_random_e2e.py:85–106  ·  view source on GitHub ↗
(
    ray_start_regular_shared_2_cpus,
    restore_data_context,
    disable_fallback_to_object_extension,
)

Source from the content-addressed store, hash-verified

83
84
85def test_random_block_order(
86 ray_start_regular_shared_2_cpus,
87 restore_data_context,
88 disable_fallback_to_object_extension,
89):
90 ctx = DataContext.get_current()
91 ctx.execution_options.preserve_order = True
92
93 # Test BlockList.randomize_block_order.
94 ds = ray.data.range(12).repartition(4)
95 ds = ds.randomize_block_order(seed=0)
96
97 results = ds.take()
98 expected = named_values("id", [6, 7, 8, 0, 1, 2, 3, 4, 5, 9, 10, 11])
99 assert results == expected
100
101 # Test LazyBlockList.randomize_block_order.
102 lazy_blocklist_ds = ray.data.range(12, override_num_blocks=4)
103 lazy_blocklist_ds = lazy_blocklist_ds.randomize_block_order(seed=0)
104 lazy_blocklist_results = lazy_blocklist_ds.take()
105 lazy_blocklist_expected = named_values("id", [6, 7, 8, 0, 1, 2, 3, 4, 5, 9, 10, 11])
106 assert lazy_blocklist_results == lazy_blocklist_expected
107
108
109# NOTE: All tests above share a Ray cluster, while the tests below do not. These

Callers

nothing calls this directly

Calls 5

named_valuesFunction · 0.90
randomize_block_orderMethod · 0.80
get_currentMethod · 0.45
repartitionMethod · 0.45
takeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…