Skip to content

Commit

Permalink
api.main: do not reset node ownership fields
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Jeny Sadadia authored and nuclearcat committed Nov 12, 2024
1 parent 63fb009 commit 61e6109
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 61e6109

Please sign in to comment.