22import unittest
33import tempfile
44import shutil
5+ import time
56import jsonlines as jl
67from data_juicer .core .tracer .ray_tracer import RayTracer
78from data_juicer .utils .unittest_utils import TEST_TAG
@@ -58,6 +59,7 @@ def test_collect_mapper_sample_basic(self):
5859
5960 # Finalize traces to write to file
6061 ray .get (tracer .finalize_traces .remote ())
62+ time .sleep (1 )
6163
6264 trace_file_path = os .path .join (self .work_dir , 'trace' , 'sample_trace-test_mapper.jsonl' )
6365 self .assertTrue (os .path .exists (trace_file_path ))
@@ -87,6 +89,7 @@ def test_collect_mapper_sample_no_change(self):
8789
8890 # Finalize traces to write to file
8991 ray .get (tracer .finalize_traces .remote ())
92+ time .sleep (1 )
9093
9194 trace_file_path = os .path .join (self .work_dir , 'trace' , 'sample_trace-test_mapper.jsonl' )
9295 # File should not exist since no samples were collected
@@ -105,6 +108,7 @@ def test_collect_mapper_sample_with_trace_keys(self):
105108
106109 # Finalize traces to write to file
107110 ray .get (tracer .finalize_traces .remote ())
111+ time .sleep (1 )
108112
109113 trace_file_path = os .path .join (self .work_dir , 'trace' , 'sample_trace-test_mapper.jsonl' )
110114 self .assertTrue (os .path .exists (trace_file_path ))
@@ -135,6 +139,7 @@ def test_collect_mapper_sample_with_missing_trace_keys(self):
135139
136140 # Finalize traces to write to file
137141 ray .get (tracer .finalize_traces .remote ())
142+ time .sleep (1 )
138143
139144 trace_file_path = os .path .join (self .work_dir , 'trace' , 'sample_trace-test_mapper.jsonl' )
140145 self .assertTrue (os .path .exists (trace_file_path ))
@@ -166,6 +171,7 @@ def test_collect_mapper_sample_not_in_op_list(self):
166171
167172 # Finalize traces to write to file
168173 ray .get (tracer .finalize_traces .remote ())
174+ time .sleep (1 )
169175
170176 trace_file_path = os .path .join (self .work_dir , 'trace' , 'sample_trace-test_mapper.jsonl' )
171177 self .assertFalse (os .path .exists (trace_file_path ))
@@ -183,6 +189,7 @@ def test_collect_filter_sample_basic(self):
183189
184190 # Finalize traces to write to file
185191 ray .get (tracer .finalize_traces .remote ())
192+ time .sleep (1 )
186193
187194 trace_file_path = os .path .join (self .work_dir , 'trace' , 'sample_trace-test_filter.jsonl' )
188195 self .assertTrue (os .path .exists (trace_file_path ))
@@ -208,6 +215,7 @@ def test_collect_filter_sample_should_keep(self):
208215
209216 # Finalize traces to write to file
210217 ray .get (tracer .finalize_traces .remote ())
218+ time .sleep (1 )
211219
212220 trace_file_path = os .path .join (self .work_dir , 'trace' , 'sample_trace-test_filter.jsonl' )
213221 self .assertFalse (os .path .exists (trace_file_path ))
@@ -225,6 +233,7 @@ def test_collect_filter_sample_not_in_op_list(self):
225233
226234 # Finalize traces to write to file
227235 ray .get (tracer .finalize_traces .remote ())
236+ time .sleep (1 )
228237
229238 trace_file_path = os .path .join (self .work_dir , 'trace' , 'sample_trace-test_filter.jsonl' )
230239 self .assertFalse (os .path .exists (trace_file_path ))
@@ -254,6 +263,7 @@ def test_collect_mapper_sample_show_num_limit(self):
254263
255264 # Finalize traces to write to file
256265 ray .get (tracer .finalize_traces .remote ())
266+ time .sleep (1 )
257267
258268 trace_file_path = os .path .join (self .work_dir , 'trace' , 'sample_trace-limited_mapper.jsonl' )
259269 self .assertTrue (os .path .exists (trace_file_path ))
@@ -288,6 +298,7 @@ def test_collect_filter_sample_show_num_limit(self):
288298
289299 # Finalize traces to write to file
290300 ray .get (tracer .finalize_traces .remote ())
301+ time .sleep (1 )
291302
292303 trace_file_path = os .path .join (self .work_dir , 'trace' , 'sample_trace-limited_filter.jsonl' )
293304 self .assertTrue (os .path .exists (trace_file_path ))
@@ -327,6 +338,7 @@ def test_finalize_traces_empty(self):
327338
328339 # Don't collect anything, just finalize
329340 ray .get (tracer .finalize_traces .remote ())
341+ time .sleep (1 )
330342
331343 # No trace files should exist
332344 trace_dir = os .path .join (self .work_dir , 'trace' )
0 commit comments