From 5ce6013105f14aff1e37b4984b3aa3d6f8b9017a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilhem=20Barth=C3=A9s?= Date: Wed, 25 Oct 2023 15:52:39 +0200 Subject: [PATCH] fix: update to pydantic 2.x.x MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guilhem Barthés --- backend/builder/tasks/task.py | 2 +- backend/builder/tasks/tasks_build_image.py | 2 +- backend/substrapp/tasks/task.py | 2 +- backend/substrapp/tasks/tasks_save_image.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/builder/tasks/task.py b/backend/builder/tasks/task.py index 459f00e99..50f59ddb3 100644 --- a/backend/builder/tasks/task.py +++ b/backend/builder/tasks/task.py @@ -34,6 +34,6 @@ def before_start(self, task_id: str, args: tuple, kwargs: dict) -> None: ) def get_task_info(self, args: tuple, kwargs: dict) -> tuple[str, str]: - function = orchestrator.Function.parse_raw(kwargs["function_serialized"]) + function = orchestrator.Function.model_validate_json(kwargs["function_serialized"]) channel_name = kwargs["channel_name"] return function.key, channel_name diff --git a/backend/builder/tasks/tasks_build_image.py b/backend/builder/tasks/tasks_build_image.py index dda71d8dc..d335fe1c4 100644 --- a/backend/builder/tasks/tasks_build_image.py +++ b/backend/builder/tasks/tasks_build_image.py @@ -20,7 +20,7 @@ # see http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-reject-on-worker-lost # and https://github.com/celery/celery/issues/5106 def build_image(task: BuildTask, function_serialized: str, channel_name: str) -> None: - function = orchestrator.Function.parse_raw(function_serialized) + function = orchestrator.Function.model_validate_json(function_serialized) attempt = 0 while attempt <= task.max_retries: diff --git a/backend/substrapp/tasks/task.py b/backend/substrapp/tasks/task.py index 9c1915192..60db3d507 100644 --- a/backend/substrapp/tasks/task.py +++ b/backend/substrapp/tasks/task.py @@ -91,7 +91,7 @@ def on_retry(self, exc: Exception, task_id: str, args: tuple, kwargs: dict[str, def split_args(self, celery_args: tuple) -> tuple[str, orchestrator.ComputeTask]: channel_name = celery_args[0] - task = orchestrator.ComputeTask.parse_raw(celery_args[1]) + task = orchestrator.ComputeTask.model_validate_json(celery_args[1]) return channel_name, task def get_task_info(self, args: tuple, kwargs: dict) -> tuple[str, str]: diff --git a/backend/substrapp/tasks/tasks_save_image.py b/backend/substrapp/tasks/tasks_save_image.py index 1ada2b6ae..15d9eaf16 100644 --- a/backend/substrapp/tasks/tasks_save_image.py +++ b/backend/substrapp/tasks/tasks_save_image.py @@ -46,7 +46,7 @@ def attempt(self) -> int: # Returns (function key, channel) def get_task_info(self, args: tuple, kwargs: dict) -> tuple[str, str]: - function = orchestrator.Function.parse_raw(kwargs["function_serialized"]) + function = orchestrator.Function.model_validate_json(kwargs["function_serialized"]) channel_name = kwargs["channel_name"] return function.key, channel_name @@ -75,7 +75,7 @@ def save_image_task(task: SaveImageTask, function_serialized: str, channel_name: logger.info("Starting save_image_task") logger.info(f"Parameters: function_serialized {function_serialized}, " f"channel_name {channel_name}") # create serialized image - function = orchestrator.Function.parse_raw(function_serialized) + function = orchestrator.Function.model_validate_json(function_serialized) container_image_tag = utils.container_image_tag_from_function(function) os.makedirs(SUBTUPLE_TMP_DIR, exist_ok=True)