Skip to content

Commit

Permalink
Fix bug in migrator function
Browse files Browse the repository at this point in the history
  • Loading branch information
jcardonnet committed Feb 23, 2024
1 parent 17dbb15 commit 2afdac0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/syft/src/syft/service/user/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from .user_roles import ServiceRole


@serializable()
class UserV1(SyftObject):
__canonical_name__ = "User"
__version__ = SYFT_OBJECT_VERSION_1
Expand Down Expand Up @@ -151,6 +152,7 @@ def check_pwd(password: str, hashed_password: str) -> bool:
)


@serializable()
class UserUpdateV1(PartialSyftObject):
__canonical_name__ = "UserUpdate"
__version__ = SYFT_OBJECT_VERSION_1
Expand Down Expand Up @@ -208,6 +210,7 @@ def str_to_role(cls, v: Any) -> Any:
mock_execution_permission: bool


@serializable()
class UserCreateV1(UserUpdateV1):
__canonical_name__ = "UserCreate"
__version__ = SYFT_OBJECT_VERSION_1
Expand Down Expand Up @@ -273,6 +276,7 @@ class UserSearch(PartialSyftObject):
name: str


@serializable()
class UserViewV1(SyftObject):
__canonical_name__ = "UserView"
__version__ = SYFT_OBJECT_VERSION_1
Expand Down Expand Up @@ -469,6 +473,7 @@ def user_to_view_user() -> List[Callable]:
"institution",
"website",
"mock_execution_permission",
"email_notifications_enabled",
]
)
]
Expand Down Expand Up @@ -552,13 +557,13 @@ def downgrade_user_view_v3_to_v2() -> List[Callable]:


# Create
@migrate(UserViewV2, UserView)
@migrate(UserCreateV2, UserCreate)
def upgrade_user_create_v2_to_v3() -> List[Callable]:
return [make_set_default(key="email_notifications_enabled", value=True)]


@migrate(UserView, UserViewV2)
def downgrade_create_view_v3_to_v2() -> List[Callable]:
def downgrade_create_create_v3_to_v2() -> List[Callable]:
return [drop(["email_notifications_enabled"])]


Expand All @@ -568,6 +573,6 @@ def upgrade_user_update_v2_to_v3() -> List[Callable]:
return [make_set_default(key="email_notifications_enabled", value=True)]


@migrate(UserUpdate, UserViewV2)
@migrate(UserUpdate, UserUpdateV2)
def downgrade_user_update_v3_to_v2() -> List[Callable]:
return [drop(["email_notifications_enabled"])]

0 comments on commit 2afdac0

Please sign in to comment.