Skip to content

Commit 06ebfb8

Browse files
ankursharmascopybara-github
authored andcommitted
fix: add utf-8 encoding to file based reads and writes of eval data
This will help manage encoding consistency between reads and writes. PiperOrigin-RevId: 784741646
1 parent 0ec69d0 commit 06ebfb8

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/google/adk/evaluation/local_eval_set_results_manager.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def save_eval_set_result(
6060
eval_set_result.eval_set_result_name + _EVAL_SET_RESULT_FILE_EXTENSION,
6161
)
6262
logger.info("Writing eval result to file: %s", eval_set_result_file_path)
63-
with open(eval_set_result_file_path, "w") as f:
63+
with open(eval_set_result_file_path, "w", encoding="utf-8") as f:
6464
f.write(json.dumps(eval_set_result_json, indent=2))
6565

6666
@override
@@ -78,7 +78,7 @@ def get_eval_set_result(
7878
)
7979
if not os.path.exists(maybe_eval_result_file_path):
8080
raise NotFoundError(f"Eval set result `{eval_set_result_id}` not found.")
81-
with open(maybe_eval_result_file_path, "r") as file:
81+
with open(maybe_eval_result_file_path, "r", encoding="utf-8") as file:
8282
eval_result_data = json.load(file)
8383
return EvalSetResult.model_validate_json(eval_result_data)
8484

‎src/google/adk/evaluation/local_eval_sets_manager.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def _validate_id(self, id_name: str, id_value: str):
315315
)
316316

317317
def _write_eval_set_to_path(self, eval_set_path: str, eval_set: EvalSet):
318-
with open(eval_set_path, "w") as f:
318+
with open(eval_set_path, "w", encoding="utf-8") as f:
319319
f.write(eval_set.model_dump_json(indent=2))
320320

321321
def _save_eval_set(self, app_name: str, eval_set_id: str, eval_set: EvalSet):

0 commit comments

Comments
 (0)