diff --git a/packages/syft/src/syft/client/client.py b/packages/syft/src/syft/client/client.py index 239c33f57a3..a88b2562541 100644 --- a/packages/syft/src/syft/client/client.py +++ b/packages/syft/src/syft/client/client.py @@ -2,6 +2,7 @@ from __future__ import annotations # stdlib +from copy import deepcopy from enum import Enum from getpass import getpass import json @@ -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) diff --git a/packages/syft/src/syft/service/request/request.py b/packages/syft/src/syft/service/request/request.py index 2f73ca0f404..46f156d9ad2 100644 --- a/packages/syft/src/syft/service/request/request.py +++ b/packages/syft/src/syft/service/request/request.py @@ -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 @@ -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