From 9de7a5476e31051b6472e99f91ab6f8a866a0d30 Mon Sep 17 00:00:00 2001 From: Koen van der Veen Date: Wed, 24 Jan 2024 15:37:34 +0100 Subject: [PATCH 1/4] fix nested syncing --- packages/syft/src/syft/client/client.py | 24 +++++++++++++++++++ .../syft/src/syft/service/request/request.py | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/packages/syft/src/syft/client/client.py b/packages/syft/src/syft/client/client.py index 239c33f57a3..80a9af05d56 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,29 @@ def create_project( project = project_create.start() return project + def sync_code_from_request(self, request): + code = deepcopy(request.code) + code.worker_pool_id = None + + 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) + nested_code.worker_pool_id = None + 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 b9a1ee7b8c5..70ee4ee81c9 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 From 3972fc0c3ba65e83d2df48b53f51710593cd0230 Mon Sep 17 00:00:00 2001 From: Koen van der Veen Date: Wed, 24 Jan 2024 16:12:15 +0100 Subject: [PATCH 2/4] merge dev --- packages/syft/src/syft/client/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/syft/src/syft/client/client.py b/packages/syft/src/syft/client/client.py index 80a9af05d56..757b2b010cb 100644 --- a/packages/syft/src/syft/client/client.py +++ b/packages/syft/src/syft/client/client.py @@ -530,14 +530,14 @@ def create_project( def sync_code_from_request(self, request): code = deepcopy(request.code) - code.worker_pool_id = None + code.worker_pool_name = None 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) - nested_code.worker_pool_id = None + nested_code.worker_pool_name = None result.append(nested_code) result += get_nested_codes(nested_code) return result From 56d02d7c75e428f195ae77b8b396de98432a81f3 Mon Sep 17 00:00:00 2001 From: Koen van der Veen Date: Wed, 24 Jan 2024 16:26:51 +0100 Subject: [PATCH 3/4] do not unset worker pool name for usercode --- packages/syft/src/syft/client/client.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/syft/src/syft/client/client.py b/packages/syft/src/syft/client/client.py index 757b2b010cb..b0aec36354d 100644 --- a/packages/syft/src/syft/client/client.py +++ b/packages/syft/src/syft/client/client.py @@ -530,14 +530,12 @@ def create_project( def sync_code_from_request(self, request): code = deepcopy(request.code) - code.worker_pool_name = None 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) - nested_code.worker_pool_name = None result.append(nested_code) result += get_nested_codes(nested_code) return result From d541a12b7807abf355dc401238f4035df7f66c4e Mon Sep 17 00:00:00 2001 From: Koen van der Veen Date: Wed, 24 Jan 2024 17:15:49 +0100 Subject: [PATCH 4/4] error handling --- packages/syft/src/syft/client/client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/syft/src/syft/client/client.py b/packages/syft/src/syft/client/client.py index b0aec36354d..a88b2562541 100644 --- a/packages/syft/src/syft/client/client.py +++ b/packages/syft/src/syft/client/client.py @@ -529,7 +529,13 @@ def create_project( return project def sync_code_from_request(self, request): - code = deepcopy(request.code) + 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 = []