@@ -89,6 +89,7 @@ def test_controller_with_single_partition(self, ray_setup):
8989 field_names = metadata .field_names ,
9090 dtypes = dtypes ,
9191 shapes = shapes ,
92+ custom_meta = None ,
9293 )
9394 )
9495 assert success
@@ -97,13 +98,18 @@ def test_controller_with_single_partition(self, ray_setup):
9798 assert partition .production_status .size (0 ) == gbs * num_n_samples
9899
99100 # Test for get production status
100- production_status = ray .get (
101+ global_index , production_status = ray .get (
101102 tq_controller .get_production_status .remote (
102103 partition_id = partition_id ,
103104 data_fields = data_fields ,
104105 )
105106 )
106- assert production_status
107+ # Verify global_index contains all expected indexes
108+ assert torch .equal (global_index , torch .tensor (range (gbs * num_n_samples ), dtype = torch .long ))
109+ # Verify all samples are produced for all fields (status should be 1)
110+ expected_production_status = torch .ones (gbs * num_n_samples , len (metadata .field_names ), dtype = torch .int8 )
111+ assert torch .equal (production_status , expected_production_status )
112+ print ("✓ Get production status returns correct global_index and production_status" )
107113
108114 # Total fields should match the number of fields we added
109115 assert partition .total_fields_num == len (data_fields )
@@ -126,14 +132,19 @@ def test_controller_with_single_partition(self, ray_setup):
126132
127133 print (f"✓ Updated production status for partition { partition_id } " )
128134
129- # Test for get consumption status
130- consumption_status = ray .get (
135+ # Test for get consumption status BEFORE consumption
136+ global_index , consumption_status = ray .get (
131137 tq_controller .get_consumption_status .remote (
132138 partition_id = partition_id ,
133139 task_name = "generate_sequences" ,
134140 )
135141 )
136- assert torch .equal (consumption_status , torch .zeros (gbs * num_n_samples ))
142+ # Verify global_index
143+ assert torch .equal (global_index , torch .tensor (range (gbs * num_n_samples ), dtype = torch .long ))
144+ # Verify all samples are NOT consumed yet (status should be 0)
145+ expected_consumption_status_before = torch .zeros (gbs * num_n_samples , dtype = torch .int8 )
146+ assert torch .equal (consumption_status , expected_consumption_status_before )
147+ print ("✓ Get consumption status returns correct global_index and status (before consumption)" )
137148
138149 # Test get metadate in fetch mode
139150 gen_meta = ray .get (
@@ -153,14 +164,19 @@ def test_controller_with_single_partition(self, ray_setup):
153164 assert torch .equal (partition .consumption_status ["generate_sequences" ], torch .ones (gbs * num_n_samples ))
154165 print ("✓ Get metadata in fetch mode correct" )
155166
156- # Test for get consumption status
157- consumption_status = ray .get (
167+ # Test for get consumption status AFTER consumption
168+ global_index , consumption_status = ray .get (
158169 tq_controller .get_consumption_status .remote (
159170 partition_id = partition_id ,
160171 task_name = "generate_sequences" ,
161172 )
162173 )
163- assert torch .equal (consumption_status , torch .ones (gbs * num_n_samples ))
174+ # Verify global_index
175+ assert torch .equal (global_index , torch .tensor (range (gbs * num_n_samples ), dtype = torch .long ))
176+ # Verify all samples are consumed (status should be 1)
177+ expected_consumption_status_after = torch .ones (gbs * num_n_samples , dtype = torch .int8 )
178+ assert torch .equal (consumption_status , expected_consumption_status_after )
179+ print ("✓ Get consumption status returns correct global_index and status (after consumption)" )
164180
165181 # Test get clear meta
166182 clear_meta = ray .get (
@@ -222,6 +238,19 @@ def test_controller_with_multi_partitions(self, ray_setup):
222238 )
223239 assert success
224240
241+ # Verify get production status returns correct data
242+ global_index_1 , production_status_1 = ray .get (
243+ tq_controller .get_production_status .remote (
244+ partition_id = partition_id_1 ,
245+ data_fields = data_fields ,
246+ )
247+ )
248+ expected_global_index_1 = torch .tensor (range (gbs_1 * num_n_samples_1 ), dtype = torch .long )
249+ assert torch .equal (global_index_1 , expected_global_index_1 )
250+ expected_production_status_1 = torch .ones (gbs_1 * num_n_samples_1 , len (data_fields ), dtype = torch .int8 )
251+ assert torch .equal (production_status_1 , expected_production_status_1 )
252+ print ("✓ Get production status for partition_1 returns correct global_index and status" )
253+
225254 # Test get metadate in fetch mode
226255 gen_meta = ray .get (
227256 tq_controller .get_metadata .remote (
@@ -234,6 +263,18 @@ def test_controller_with_multi_partitions(self, ray_setup):
234263 )
235264 assert gen_meta
236265
266+ # Verify get consumption status after fetch (samples should be consumed)
267+ global_index_1_consumed , consumption_status_1 = ray .get (
268+ tq_controller .get_consumption_status .remote (
269+ partition_id = partition_id_1 ,
270+ task_name = "generate_sequences" ,
271+ )
272+ )
273+ assert torch .equal (global_index_1_consumed , expected_global_index_1 )
274+ expected_consumption_status_1 = torch .ones (gbs_1 * num_n_samples_1 , dtype = torch .int8 )
275+ assert torch .equal (consumption_status_1 , expected_consumption_status_1 )
276+ print ("✓ Get consumption status for partition_1 returns correct global_index and status (after fetch)" )
277+
237278 # Test get clear meta
238279 clear_meta = ray .get (
239280 tq_controller .get_metadata .remote (
@@ -282,6 +323,31 @@ def test_controller_with_multi_partitions(self, ray_setup):
282323 )
283324 assert success
284325
326+ # Verify get production status for partition_2
327+ global_index_2 , production_status_2 = ray .get (
328+ tq_controller .get_production_status .remote (
329+ partition_id = partition_id_2 ,
330+ data_fields = data_fields ,
331+ )
332+ )
333+ expected_global_index_2 = torch .tensor (range (part1_index_range , part2_index_range + part1_index_range ), dtype = torch .long )
334+ assert torch .equal (global_index_2 , expected_global_index_2 )
335+ expected_production_status_2 = torch .ones (part2_index_range , len (data_fields ), dtype = torch .int8 )
336+ assert torch .equal (production_status_2 , expected_production_status_2 )
337+ print ("✓ Get production status for partition_2 returns correct global_index and status" )
338+
339+ # Verify get consumption status for partition_2 (before consumption - should be all zeros)
340+ global_index_2_consumed , consumption_status_2 = ray .get (
341+ tq_controller .get_consumption_status .remote (
342+ partition_id = partition_id_2 ,
343+ task_name = "generate_sequences" ,
344+ )
345+ )
346+ assert torch .equal (global_index_2_consumed , expected_global_index_2 )
347+ expected_consumption_status_2 = torch .zeros (part2_index_range , dtype = torch .int8 )
348+ assert torch .equal (consumption_status_2 , expected_consumption_status_2 )
349+ print ("✓ Get consumption status for partition_2 returns correct global_index and status (before consumption)" )
350+
285351 # Clear partition 1
286352 partition_index_range_1 = ray .get (tq_controller .get_partition_index_range .remote (partition_id_1 ))
287353 assert partition_index_range_1
0 commit comments