From 9eabc7a10ed21b914268b76219eb381a9b24487d Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Fri, 8 Nov 2024 11:26:44 +0100 Subject: [PATCH] Fix encoding issue of job metadata in `on_job_done` #657 --- CHANGELOG.md | 1 + openeo/extra/job_management.py | 2 +- openeo/udf/xarraydatacube.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04c5840bd..468192504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - `MultiBackendJobManager`: Fix issue with duplicate job starting across multiple backends ([#654](https://github.com/Open-EO/openeo-python-client/pull/654)) +- `MultiBackendJobManager`: Fix encoding issue of job metadata in `on_job_done` ([#657](https://github.com/Open-EO/openeo-python-client/issues/657)) ## [0.34.0] - 2024-10-31 diff --git a/openeo/extra/job_management.py b/openeo/extra/job_management.py index beb37ae57..8ccbae04f 100644 --- a/openeo/extra/job_management.py +++ b/openeo/extra/job_management.py @@ -596,7 +596,7 @@ def on_job_done(self, job: BatchJob, row): self.ensure_job_dir_exists(job.job_id) job.get_results().download_files(target=job_dir) - with open(metadata_path, "w") as f: + with metadata_path.open("w", encoding="utf-8") as f: json.dump(job_metadata, f, ensure_ascii=False) def on_job_error(self, job: BatchJob, row): diff --git a/openeo/udf/xarraydatacube.py b/openeo/udf/xarraydatacube.py index f01590222..05dd5311d 100644 --- a/openeo/udf/xarraydatacube.py +++ b/openeo/udf/xarraydatacube.py @@ -345,7 +345,7 @@ def to_json_file(cls, array: xarray.DataArray, path: Union[str, Path]): jsonarray['coords'][i.name]['attrs']['shape'] = list(i.shape) # custom print so resulting json file is humanly easy to read # TODO: make this human friendly JSON format optional and allow compact JSON too. - with Path(path).open("w") as f: + with Path(path).open("w", encoding="utf-8") as f: def custom_print(data_structure, indent=1): f.write("{\n") needs_comma = False