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 repr for client.settings #8814

Merged
merged 4 commits into from
May 14, 2024
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
3 changes: 3 additions & 0 deletions packages/syft/src/syft/client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,9 @@ def __getitem__(self, key: str | int) -> Any:
raise NotImplementedError

def _repr_html_(self) -> Any:
if self.path == "settings":
return self.get()._repr_html_()

if not hasattr(self, "get_all"):
return NotImplementedError
results = self.get_all()
Expand Down
20 changes: 20 additions & 0 deletions packages/syft/src/syft/service/settings/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# stdlib
from collections.abc import Callable
from typing import Any

# relative
from ...abstract_node import NodeSideType
Expand All @@ -16,6 +17,8 @@
from ...types.transforms import drop
from ...types.transforms import make_set_default
from ...types.uid import UID
from ...util import options
from ...util.colors import SURFACE


@serializable()
Expand Down Expand Up @@ -74,6 +77,23 @@ class NodeSettings(SyftObject):
association_request_auto_approval: bool
default_worker_pool: str = DEFAULT_WORKER_POOL_NAME

def _repr_html_(self) -> Any:
return f"""
<style>
.syft-settings {{color: {SURFACE[options.color_theme]};}}
</style>
<div class='syft-settings'>
<h3>Settings</h3>
<p><strong>Id: </strong>{self.id}</p>
<p><strong>Name: </strong>{self.name}</p>
<p><strong>Organization: </strong>{self.organization}</p>
<p><strong>Deployed on: </strong>{self.deployed_on}</p>
<p><strong>Signup enabled: </strong>{self.signup_enabled}</p>
<p><strong>Admin email: </strong>{self.admin_email}</p>
</div>

"""


@serializable()
class NodeSettingsV2(SyftObject):
Expand Down
Loading