Skip to content

Commit

Permalink
Merge branch 'dev' into eelco/execute-on-mock
Browse files Browse the repository at this point in the history
  • Loading branch information
koenvanderveen authored Jan 24, 2024
2 parents 75b8458 + a708983 commit 4879553
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
28 changes: 28 additions & 0 deletions packages/syft/src/syft/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

# stdlib
from copy import deepcopy
from enum import Enum
from getpass import getpass
import json
Expand Down Expand Up @@ -527,6 +528,33 @@ def create_project(
project = project_create.start()
return project

def sync_code_from_request(self, request):
code = request.code
if isinstance(code, SyftError):
return code
elif code is None:
return SyftError(message="no code inside request")

code = deepcopy(code)

def get_nested_codes(code):
result = []
for __, (linked_code_obj, _) in code.nested_codes.items():
nested_code = linked_code_obj.resolve
nested_code = deepcopy(nested_code)
result.append(nested_code)
result += get_nested_codes(nested_code)
return result

nested_codes = get_nested_codes(request.code)

for c in nested_codes + [code]:
res = self.code.submit(c)
if isinstance(res, SyftError):
return res
self._fetch_api(self.credentials)
return SyftSuccess(message="User Code Submitted")

@property
def authed(self) -> bool:
return bool(self.credentials)
Expand Down
4 changes: 2 additions & 2 deletions packages/syft/src/syft/service/request/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ def accept_by_depositing_result(self, result: Any, force: bool = False):

is_approved = change.approved

permission_request = self.approve()
permission_request = self.approve(approve_nested=True)
if isinstance(permission_request, SyftError):
return permission_request

Expand Down Expand Up @@ -694,7 +694,7 @@ def accept_by_depositing_result(self, result: Any, force: bool = False):
return result_request
self = result_request

approved = self.approve(disable_warnings=True)
approved = self.approve(disable_warnings=True, approve_nested=True)
if isinstance(approved, SyftError):
return approved

Expand Down

0 comments on commit 4879553

Please sign in to comment.