@@ -49,7 +49,9 @@ def write_benchmark_result_to_disk(
4949 _output_dir .mkdir (exist_ok = True , parents = True )
5050 (_output_dir / benchmark_name ).mkdir (exist_ok = True )
5151
52- with (_output_dir / benchmark_name / RESULT_FILENAME ).open ("w" ) as json_file :
52+ with open (
53+ _output_dir / benchmark_name / RESULT_FILENAME , mode = "w" , encoding = "utf-8"
54+ ) as json_file :
5355 json_as_str = json .loads (result .model_dump_json ()) # type: ignore
5456 json .dump (json_as_str , json_file , indent = 2 )
5557
@@ -71,7 +73,9 @@ def load_benchmark_result_from_disk(
7173 _results_dir = Path (results_dir )
7274 benchmark_subdir = _results_dir / benchmark_class .name
7375
74- with (benchmark_subdir / RESULT_FILENAME ).open ("r" , encoding = "utf-8" ) as json_file :
76+ with open (
77+ benchmark_subdir / RESULT_FILENAME , mode = "r" , encoding = "utf-8"
78+ ) as json_file :
7579 json_data = json .load (json_file )
7680
7781 return benchmark_class .result_class (** json_data ) # type: ignore
@@ -142,8 +146,8 @@ def write_scores_to_disk(
142146 """
143147 _output_dir = Path (output_dir )
144148 _output_dir .mkdir (exist_ok = True , parents = True )
145- with (_output_dir / SCORE_FILENAME ). open ( "w" ) as json_file :
146- json .dump (scores , json_file , indent = 2 )
149+ with open (_output_dir / SCORE_FILENAME , "w" , encoding = "utf-8" ) as f :
150+ json .dump (scores , f , indent = 2 )
147151
148152
149153def load_score_from_disk (
@@ -160,8 +164,9 @@ def load_score_from_disk(
160164 A dictionary of scores where the keys are the
161165 benchmark names.
162166 """
163- with (Path (output_dir ) / SCORE_FILENAME ).open ("w" ) as json_file :
164- scores = json .load (json_file )
167+ with open (Path (output_dir ) / SCORE_FILENAME , mode = "r" , encoding = "utf-8" ) as f :
168+ scores = json .load (f )
169+
165170 return scores
166171
167172
@@ -213,7 +218,7 @@ def write_model_output_to_disk(
213218 json_path = Path (tmpdir ) / MODEL_OUTPUT_JSON_FILENAME
214219 arrays_path = Path (tmpdir ) / MODEL_OUTPUT_ARRAYS_FILENAME
215220
216- with json_path . open ("w " ) as json_file :
221+ with open (json_path , "w" , encoding = "utf-8 " ) as json_file :
217222 json .dump (data , json_file )
218223
219224 np .savez (arrays_path , ** arrays )
0 commit comments