Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to directly specify enclave route as a string #9124

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"import syft as sy\n",
"from syft.abstract_server import ServerType\n",
"from syft.service.code.user_code import UserCodeStatus\n",
"from syft.service.network.routes import HTTPServerRoute\n",
"from syft.service.project.project import ProjectCode\n",
"from syft.service.response import SyftSuccess\n",
"from syft.types.uid import UID"
Expand Down Expand Up @@ -484,8 +483,7 @@
"metadata": {},
"outputs": [],
"source": [
"route = HTTPServerRoute(host_or_ip=CANADA_ENCLAVE_HOST, port=CANADA_ENCLAVE_PORT)\n",
"do_canada_client.enclaves.add(route=route)"
"do_canada_client.enclaves.add(url=f\"http://{CANADA_ENCLAVE_HOST}:{CANADA_ENCLAVE_PORT}\")"
]
},
{
Expand Down
18 changes: 16 additions & 2 deletions packages/syft/src/syft/service/enclave/datasite_enclave_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
# relative
from ...serde.serializable import serializable
from ...store.document_store import DocumentStore
from ...types.server_url import ServerURL
from ...types.uid import UID
from ..action.action_object import ActionObject
from ..action.action_permissions import ActionObjectPermission
from ..action.action_permissions import ActionPermission
from ..code.user_code import UserCode
from ..context import AuthedServiceContext
from ..model.model import ModelRef
from ..network.routes import ServerRouteType
from ..network.routes import HTTPServerRoute
from ..response import SyftError
from ..response import SyftSuccess
from ..service import AbstractService
Expand Down Expand Up @@ -41,9 +42,22 @@ def __init__(self, store: DocumentStore) -> None:
roles=ADMIN_ROLE_LEVEL,
)
def add(
self, context: AuthedServiceContext, route: ServerRouteType
self,
context: AuthedServiceContext,
route: HTTPServerRoute | None = None,
url: str | None = None,
) -> SyftSuccess | SyftError:
"""Add an Enclave to the network."""
if route is None and url is None:
return SyftError(message="Either route or url must be provided.")
if url:
parsed_url = ServerURL.from_url(url)
route = HTTPServerRoute(
host_or_ip=parsed_url.host_or_ip,
port=parsed_url.port,
protocol=parsed_url.protocol,
)

enclave = EnclaveInstance(route=route)
result = self.stash.set(
credentials=context.credentials,
Expand Down
1 change: 0 additions & 1 deletion packages/syft/src/syft/service/enclave/enclave.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class EnclaveInstance(SyftObject):
@classmethod
def initialize_values(cls, values: dict[str, Any]) -> dict[str, Any]:
is_being_created = "id" not in values

if is_being_created and "route" in values:
connection = route_to_connection(values["route"])
metadata = connection.get_server_metadata(credentials=None)
Expand Down
Loading