66from unittest .mock import patch , mock_open
77
88
9+ # Get the path to process_result.py dynamically
10+ SCRIPT_DIR = Path (__file__ ).parent
11+ PROCESS_RESULT_PATH = SCRIPT_DIR / 'process_result.py'
12+
13+
914@pytest .fixture
1015def sample_benchmark_result ():
1116 """Sample benchmark result JSON data."""
@@ -39,15 +44,6 @@ def basic_env_vars():
3944 }
4045
4146
42- @pytest .fixture
43- def temp_result_file (tmp_path , sample_benchmark_result ):
44- """Create a temporary benchmark result file."""
45- result_file = tmp_path / 'test_result.json'
46- with open (result_file , 'w' ) as f :
47- json .dump (sample_benchmark_result , f )
48- return result_file
49-
50-
5147def test_basic_processing (tmp_path , sample_benchmark_result , basic_env_vars ):
5248 """Test basic processing of benchmark results."""
5349 # Create result file
@@ -62,7 +58,7 @@ def test_basic_processing(tmp_path, sample_benchmark_result, basic_env_vars):
6258 try :
6359 with patch .dict (os .environ , basic_env_vars ):
6460 # Import and execute the script
65- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
61+ exec (open (PROCESS_RESULT_PATH ).read ())
6662
6763 # Check output file was created
6864 output_file = tmp_path / 'agg_test_result.json'
@@ -109,7 +105,7 @@ def test_ms_to_seconds_conversion(tmp_path, basic_env_vars):
109105
110106 try :
111107 with patch .dict (os .environ , basic_env_vars ):
112- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
108+ exec (open (PROCESS_RESULT_PATH ).read ())
113109
114110 output_file = tmp_path / 'agg_test_result.json'
115111 with open (output_file ) as f :
@@ -145,7 +141,7 @@ def test_tpot_to_intvty_conversion(tmp_path, basic_env_vars):
145141
146142 try :
147143 with patch .dict (os .environ , basic_env_vars ):
148- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
144+ exec (open (PROCESS_RESULT_PATH ).read ())
149145
150146 output_file = tmp_path / 'agg_test_result.json'
151147 with open (output_file ) as f :
@@ -185,7 +181,7 @@ def test_mtp_mode_included(tmp_path, sample_benchmark_result, basic_env_vars):
185181
186182 try :
187183 with patch .dict (os .environ , env_vars ):
188- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
184+ exec (open (PROCESS_RESULT_PATH ).read ())
189185
190186 output_file = tmp_path / 'agg_test_result.json'
191187 with open (output_file ) as f :
@@ -209,7 +205,7 @@ def test_mtp_mode_not_included(tmp_path, sample_benchmark_result, basic_env_vars
209205
210206 try :
211207 with patch .dict (os .environ , basic_env_vars ):
212- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
208+ exec (open (PROCESS_RESULT_PATH ).read ())
213209
214210 output_file = tmp_path / 'agg_test_result.json'
215211 with open (output_file ) as f :
@@ -236,7 +232,7 @@ def test_prefill_decode_gpus_explicit(tmp_path, sample_benchmark_result, basic_e
236232
237233 try :
238234 with patch .dict (os .environ , env_vars ):
239- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
235+ exec (open (PROCESS_RESULT_PATH ).read ())
240236
241237 output_file = tmp_path / 'agg_test_result.json'
242238 with open (output_file ) as f :
@@ -262,7 +258,7 @@ def test_prefill_decode_gpus_defaults_to_tp(tmp_path, sample_benchmark_result, b
262258
263259 try :
264260 with patch .dict (os .environ , basic_env_vars ):
265- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
261+ exec (open (PROCESS_RESULT_PATH ).read ())
266262
267263 output_file = tmp_path / 'agg_test_result.json'
268264 with open (output_file ) as f :
@@ -299,7 +295,7 @@ def test_different_tp_sizes(tmp_path, sample_benchmark_result, basic_env_vars):
299295
300296 try :
301297 with patch .dict (os .environ , env_vars ):
302- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
298+ exec (open (PROCESS_RESULT_PATH ).read ())
303299
304300 output_file = tmp_path / 'agg_test_result.json'
305301 with open (output_file ) as f :
@@ -329,7 +325,7 @@ def test_different_ep_sizes(tmp_path, sample_benchmark_result, basic_env_vars):
329325
330326 try :
331327 with patch .dict (os .environ , env_vars ):
332- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
328+ exec (open (PROCESS_RESULT_PATH ).read ())
333329
334330 output_file = tmp_path / 'agg_test_result.json'
335331 with open (output_file ) as f :
@@ -352,7 +348,7 @@ def test_output_file_content_structure(tmp_path, sample_benchmark_result, basic_
352348
353349 try :
354350 with patch .dict (os .environ , basic_env_vars ):
355- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
351+ exec (open (PROCESS_RESULT_PATH ).read ())
356352
357353 output_file = tmp_path / 'agg_test_result.json'
358354 with open (output_file ) as f :
@@ -398,7 +394,7 @@ def test_complex_benchmark_result(tmp_path, basic_env_vars):
398394
399395 try :
400396 with patch .dict (os .environ , basic_env_vars ):
401- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
397+ exec (open (PROCESS_RESULT_PATH ).read ())
402398
403399 output_file = tmp_path / 'agg_test_result.json'
404400 with open (output_file ) as f :
@@ -438,7 +434,7 @@ def test_dp_attention_values(tmp_path, sample_benchmark_result, basic_env_vars):
438434
439435 try :
440436 with patch .dict (os .environ , env_vars ):
441- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
437+ exec (open (PROCESS_RESULT_PATH ).read ())
442438
443439 output_file = tmp_path / 'agg_test_result.json'
444440 with open (output_file ) as f :
@@ -467,7 +463,7 @@ def test_different_frameworks(tmp_path, sample_benchmark_result, basic_env_vars)
467463
468464 try :
469465 with patch .dict (os .environ , env_vars ):
470- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
466+ exec (open (PROCESS_RESULT_PATH ).read ())
471467
472468 output_file = tmp_path / 'agg_test_result.json'
473469 with open (output_file ) as f :
@@ -496,7 +492,7 @@ def test_different_precisions(tmp_path, sample_benchmark_result, basic_env_vars)
496492
497493 try :
498494 with patch .dict (os .environ , env_vars ):
499- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
495+ exec (open (PROCESS_RESULT_PATH ).read ())
500496
501497 output_file = tmp_path / 'agg_test_result.json'
502498 with open (output_file ) as f :
@@ -531,7 +527,7 @@ def test_throughput_calculations(tmp_path, basic_env_vars):
531527
532528 try :
533529 with patch .dict (os .environ , env_vars ):
534- exec (open ('/home/runner/work/InferenceMAX/InferenceMAX/utils/process_result.py' ).read ())
530+ exec (open (PROCESS_RESULT_PATH ).read ())
535531
536532 output_file = tmp_path / 'agg_test_result.json'
537533 with open (output_file ) as f :
0 commit comments