Skip to content

Commit

Permalink
Merge branch 'eelco/filter-nodediff' of github.com:OpenMined/PySyft i…
Browse files Browse the repository at this point in the history
…nto eelco/filter-nodediff
  • Loading branch information
eelcovdw committed May 23, 2024
2 parents eeb602c + a4f136a commit cf6f243
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/syft/src/syft/service/code/user_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,13 @@ def _coll_repr_(self) -> dict[str, Any]:
def user(self) -> UserView | SyftError:
api = APIRegistry.api_for(
node_uid=self.syft_node_location,
user_verify_key=self.user_verify_key,
user_verify_key=self.syft_client_verify_key,
)
if api is None:
return SyftError(
message=f"Can't access Syft API. You must login to {self.syft_node_location}"
)
return api.services.user.get_current_user()
return api.services.user.get_by_verify_key(self.user_verify_key)

@property
def status(self) -> UserCodeStatusCollection | SyftError:
Expand Down
9 changes: 6 additions & 3 deletions packages/syft/src/syft/service/request/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,14 @@ def approve(
)
if message and metadata and metadata.show_warnings and not disable_warnings:
prompt_warning_message(message=message, confirm=True)
msg = (
"Approving request ",
f"on change {self.code.service_func_name} " if is_code_request else "",
f"for domain {api.node_name}",
)

print(f"Approving request for domain {api.node_name}")
print("".join(msg))
res = api.services.request.apply(self.id, **kwargs)
# if isinstance(res, SyftSuccess):

return res

def deny(self, reason: str) -> SyftSuccess | SyftError:
Expand Down
19 changes: 18 additions & 1 deletion packages/syft/src/syft/service/user/user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from .user import UserViewPage
from .user import check_pwd
from .user import salt_and_hash_password
from .user_roles import ADMIN_ROLE_LEVEL
from .user_roles import DATA_OWNER_ROLE_LEVEL
from .user_roles import DATA_SCIENTIST_ROLE_LEVEL
from .user_roles import GUEST_ROLE_LEVEL
Expand Down Expand Up @@ -220,7 +221,23 @@ def get_current_user(self, context: AuthedServiceContext) -> UserView | SyftErro
credentials=context.credentials, verify_key=context.credentials
)
if result.is_ok():
# this seems weird that we get back None as Ok(None)
user = result.ok()
if user:
return user.to(UserView)
else:
SyftError(message="User not found!")
return SyftError(message=str(result.err()))

@service_method(
path="user.get_by_verify_key", name="get_by_verify_key", roles=ADMIN_ROLE_LEVEL
)
def get_by_verify_key_endpoint(
self, context: AuthedServiceContext, verify_key: SyftVerifyKey
) -> UserView | SyftError:
result = self.stash.get_by_verify_key(
credentials=context.credentials, verify_key=verify_key
)
if result.is_ok():
user = result.ok()
if user:
return user.to(UserView)
Expand Down

0 comments on commit cf6f243

Please sign in to comment.