From 1e988972826ffd99a931a1914811c01e6881e8ce Mon Sep 17 00:00:00 2001 From: Andrew Trask Date: Sun, 4 Aug 2024 00:11:19 -0400 Subject: [PATCH 1/4] Add some logging --- packages/syft/src/syft/client/registry.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/syft/src/syft/client/registry.py b/packages/syft/src/syft/client/registry.py index 100bc0af96d..39414f1bfdb 100644 --- a/packages/syft/src/syft/client/registry.py +++ b/packages/syft/src/syft/client/registry.py @@ -210,8 +210,7 @@ def check_datasite(datasite: dict) -> dict[Any, Any] | None: online = res.json()["status"] == "ok" elif "detail" in res.json(): online = True - except Exception as e: - print(e) + except Exception: online = False if online: version = datasite.get("version", None) @@ -246,7 +245,9 @@ def _repr_html_(self) -> str: if len(on) == 0: return "(no gateways online - try syft.gateways.all_networks to see offline gateways)" df = pd.DataFrame(on) - + print( + "Add your datasite to this list: https://github.com/OpenMined/NetworkRegistry/" + ) return df._repr_html_() # type: ignore @staticmethod From 624637caea1713b0dab8bc0234b8e276fa4faa0c Mon Sep 17 00:00:00 2001 From: Andrew Trask Date: Sun, 4 Aug 2024 01:07:45 -0400 Subject: [PATCH 2/4] Improve logging and remove test section which is no longer valid --- packages/syft/src/syft/client/registry.py | 52 ++++++++++++++++++- .../src/syft/protocol/protocol_version.json | 11 ++++ tests/integration/local/gateway_local_test.py | 24 +++++---- 3 files changed, 74 insertions(+), 13 deletions(-) diff --git a/packages/syft/src/syft/client/registry.py b/packages/syft/src/syft/client/registry.py index 39414f1bfdb..ed16c078df9 100644 --- a/packages/syft/src/syft/client/registry.py +++ b/packages/syft/src/syft/client/registry.py @@ -18,6 +18,7 @@ from ..service.network.server_peer import ServerPeerConnectionStatus from ..service.response import SyftException from ..types.server_url import ServerURL +from ..types.syft_object import SyftObject from ..util.constants import DEFAULT_TIMEOUT from .client import SyftClient as Client @@ -186,6 +187,51 @@ def __getitem__(self, key: str | int) -> Client: raise KeyError(f"Invalid key: {key} for {on}") +class Datasite(SyftObject): + __canonical_name__ = "ServerMetadata" + # __version__ = SYFT_OBJECT_VERSION_1 + + name: str + host_or_ip: str + protocol: str + admin_email: str + website: str + slack: str + slack_channel: str + + __attr_searchable__ = [ + "name", + "host_or_ip", + "protocol", + "port", + "admin_email", + "website", + "slack", + "slack_channel", + ] + __attr_unique__ = [ + "name", + "host_or_ip", + "protocol", + "port", + "admin_email", + "website", + "slack", + "slack_channel", + ] + __repr_attrs__ = [ + "name", + "host_or_ip", + "protocol", + "port", + "admin_email", + "website", + "slack", + "slack_channel", + ] + __table_sort_attr__ = "name" + + class DatasiteRegistry: def __init__(self) -> None: self.all_datasites: list[dict] = [] @@ -244,11 +290,13 @@ def _repr_html_(self) -> str: on = self.online_datasites if len(on) == 0: return "(no gateways online - try syft.gateways.all_networks to see offline gateways)" - df = pd.DataFrame(on) + + # df = pd.DataFrame(on) print( "Add your datasite to this list: https://github.com/OpenMined/NetworkRegistry/" ) - return df._repr_html_() # type: ignore + # return df._repr_html_() # type: ignore + return ([Datasite(**ds) for ds in on])._repr_html_() @staticmethod def create_client(datasite: dict[str, Any]) -> Client: diff --git a/packages/syft/src/syft/protocol/protocol_version.json b/packages/syft/src/syft/protocol/protocol_version.json index 49f2dcd4d8e..223ad28d2e9 100644 --- a/packages/syft/src/syft/protocol/protocol_version.json +++ b/packages/syft/src/syft/protocol/protocol_version.json @@ -7,5 +7,16 @@ }, "3": { "release_name": "0.9.0.json" + }, + "dev": { + "object_versions": { + "EnclaveMetadata": { + "1": { + "version": 1, + "hash": "8d2dfafa01ec909c080a790cf15a8fc78e00382d3bfe6207098ceb25a60b9c53", + "action": "add" + } + } + } } } diff --git a/tests/integration/local/gateway_local_test.py b/tests/integration/local/gateway_local_test.py index e10e9cb1540..909bb3dd598 100644 --- a/tests/integration/local/gateway_local_test.py +++ b/tests/integration/local/gateway_local_test.py @@ -15,7 +15,6 @@ from syft.client.gateway_client import GatewayClient from syft.service.network.network_service import ServerPeerAssociationStatus from syft.service.network.server_peer import ServerPeer -from syft.service.network.server_peer import ServerPeerConnectionStatus from syft.service.network.utils import PeerHealthCheckTask from syft.service.request.request import Request from syft.service.response import SyftSuccess @@ -164,16 +163,19 @@ def test_create_gateway( assert isinstance(result, SyftSuccess) time.sleep(PeerHealthCheckTask.repeat_time * 2 + 1) - assert len(sy.datasites.all_datasites) == 2 - assert len(sy.datasites.online_datasites) == 2 - # check for peer connection status - for peer in gateway_client.api.services.network.get_all_peers(): - assert peer.ping_status == ServerPeerConnectionStatus.ACTIVE - - # check the guest client - client = gateway_webserver.client - assert isinstance(client, GatewayClient) - assert client.metadata.server_type == ServerType.GATEWAY.value + + # TRASK: i've changed the functionality here so that + # sy.datasites always goes out to the network + # assert len(sy.datasites.all_datasites) == 2 + # assert len(sy.datasites.online_datasites) == 2 + # # check for peer connection status + # for peer in gateway_client.api.services.network.get_all_peers(): + # assert peer.ping_status == ServerPeerConnectionStatus.ACTIVE + + # # check the guest client + # client = gateway_webserver.client + # assert isinstance(client, GatewayClient) + # assert client.metadata.server_type == ServerType.GATEWAY.value @pytest.mark.local_server From b0ff13721eb9f5dc118e6a28d218f8c7308dcfd9 Mon Sep 17 00:00:00 2001 From: Andrew Trask Date: Sun, 4 Aug 2024 01:11:44 -0400 Subject: [PATCH 3/4] Remove protocol_Version change --- packages/syft/src/syft/protocol/protocol_version.json | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/packages/syft/src/syft/protocol/protocol_version.json b/packages/syft/src/syft/protocol/protocol_version.json index 223ad28d2e9..49f2dcd4d8e 100644 --- a/packages/syft/src/syft/protocol/protocol_version.json +++ b/packages/syft/src/syft/protocol/protocol_version.json @@ -7,16 +7,5 @@ }, "3": { "release_name": "0.9.0.json" - }, - "dev": { - "object_versions": { - "EnclaveMetadata": { - "1": { - "version": 1, - "hash": "8d2dfafa01ec909c080a790cf15a8fc78e00382d3bfe6207098ceb25a60b9c53", - "action": "add" - } - } - } } } From 7946ca625123f8b362f474baff2ac77de5e646ab Mon Sep 17 00:00:00 2001 From: Andrew Trask Date: Sun, 4 Aug 2024 01:31:52 -0400 Subject: [PATCH 4/4] Add version to printout --- packages/syft/src/syft/client/registry.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/syft/src/syft/client/registry.py b/packages/syft/src/syft/client/registry.py index ed16c078df9..1d06166d1b3 100644 --- a/packages/syft/src/syft/client/registry.py +++ b/packages/syft/src/syft/client/registry.py @@ -193,6 +193,7 @@ class Datasite(SyftObject): name: str host_or_ip: str + version: str protocol: str admin_email: str website: str @@ -202,32 +203,35 @@ class Datasite(SyftObject): __attr_searchable__ = [ "name", "host_or_ip", - "protocol", + "version", "port", "admin_email", "website", "slack", "slack_channel", + "protocol", ] __attr_unique__ = [ "name", "host_or_ip", - "protocol", + "version", "port", "admin_email", "website", "slack", "slack_channel", + "protocol", ] __repr_attrs__ = [ "name", "host_or_ip", - "protocol", + "version", "port", "admin_email", "website", "slack", "slack_channel", + "protocol", ] __table_sort_attr__ = "name"