From 78127d9fde0d8b4de68631d39a614b876d12aa69 Mon Sep 17 00:00:00 2001 From: ThibaultFy <50656860+ThibaultFy@users.noreply.github.com> Date: Tue, 12 Sep 2023 11:29:34 +0200 Subject: [PATCH] fix: convert round_idx metadata to int in Performances (#387) Signed-off-by: ThibaultFy <50656860+ThibaultFy@users.noreply.github.com> --- CHANGELOG.md | 6 ++++++ substra/sdk/backends/local/dal.py | 6 +++++- substra/sdk/backends/remote/backend.py | 6 +++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b09a548a..dd7837a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +### Fixed + +- Convert `round_idx` from metadata to `int` when creating `Performances` to fix Pydantic warning ([#387](https://github.com/Substra/substra/pull/387)) + ## [0.48.0](https://github.com/Substra/substra/releases/tag/0.48.0) - 2023-09-08 +### Changed + - Update to pydantic 2.3.0 ([#375](https://github.com/Substra/substra/pull/375)) ## [0.47.0](https://github.com/Substra/substra/releases/tag/0.47.0) - 2023-09-07 diff --git a/substra/sdk/backends/local/dal.py b/substra/sdk/backends/local/dal.py index 135a19fa..f804a3c4 100644 --- a/substra/sdk/backends/local/dal.py +++ b/substra/sdk/backends/local/dal.py @@ -142,7 +142,11 @@ def get_performances(self, key: str) -> models.Performances: performances.worker.append(task.worker) performances.task_key.append(task.key) performances.task_rank.append(task.rank) - performances.round_idx.append(task.metadata.get("round_idx")) + try: + round_idx = int(task.metadata.get("round_idx")) + except TypeError: + round_idx = None + performances.round_idx.append(round_idx) performances.identifier.append(output.identifier) performances.performance.append(output.asset) diff --git a/substra/sdk/backends/remote/backend.py b/substra/sdk/backends/remote/backend.py index 8ea83b2e..2d115985 100644 --- a/substra/sdk/backends/remote/backend.py +++ b/substra/sdk/backends/remote/backend.py @@ -97,7 +97,11 @@ def get_performances(self, key: str) -> models.Performances: performances.worker.append(test_task["compute_task"]["worker"]) performances.task_key.append(test_task["compute_task"]["key"]) performances.task_rank.append(test_task["compute_task"]["rank"]) - performances.round_idx.append(test_task["compute_task"]["round_idx"]) + try: + round_idx = int(test_task["compute_task"]["round_idx"]) + except TypeError: + round_idx = None + performances.round_idx.append(round_idx) performances.identifier.append(test_task["identifier"]) performances.performance.append(test_task["perf"])