From 650b11911a4027be7ce0a3c8430c2c9224ac1dae Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Tue, 29 Oct 2024 19:27:10 +0530 Subject: [PATCH] api.main: do not reset node ownership fields On update node operation, node ownership fields shouldn't be changed such as `owner` and `submitter`. Replace pydantic v1 functions with pydantic v2 following the package upgrade. Use `model_dump` and `model_copy` instead of older version functions. Signed-off-by: Jeny Sadadia --- api/main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/main.py b/api/main.py index 7c2b4b26..a235bab3 100644 --- a/api/main.py +++ b/api/main.py @@ -665,8 +665,9 @@ async def put_node(node_id: str, node: Node, # Sanity checks # Note: do not update node ownership fields, don't update 'state' # until we've checked the state transition is valid. - update_data = node.dict(exclude={'user', 'user_groups', 'state'}) - new_node_def = node_from_id.copy(update=update_data) + update_data = node.model_dump( + exclude={'owner', 'submitter', 'user_groups', 'state'}) + new_node_def = node_from_id.model_copy(update=update_data) # 1- Parse and validate node to specific subtype specialized_node = parse_node_obj(new_node_def)