From c4666b346f8df9cfebe8bda4734cde342c434206 Mon Sep 17 00:00:00 2001 From: teo Date: Wed, 22 May 2024 11:51:14 +0300 Subject: [PATCH 1/3] raise proper exception for syft responses --- packages/syft/src/syft/service/response.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/syft/src/syft/service/response.py b/packages/syft/src/syft/service/response.py index 37227046c5c..9927bf67e9b 100644 --- a/packages/syft/src/syft/service/response.py +++ b/packages/syft/src/syft/service/response.py @@ -16,6 +16,11 @@ class SyftResponseMessage(SyftBaseModel): _bool: bool = True require_api_update: bool = False + def __getattr__(self, name: str) -> Any: + raise Exception( + f"You have tried accessing `{name}` on a {type(self).__name__} with message: {self.message}" + ) + def __bool__(self) -> bool: return self._bool From d0eddb4f3b9e5b265183a055f07e8f1b49040c82 Mon Sep 17 00:00:00 2001 From: teo Date: Wed, 22 May 2024 12:28:26 +0300 Subject: [PATCH 2/3] fix get_attr _bool --- packages/syft/src/syft/service/response.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/syft/src/syft/service/response.py b/packages/syft/src/syft/service/response.py index 9927bf67e9b..69e4b02c836 100644 --- a/packages/syft/src/syft/service/response.py +++ b/packages/syft/src/syft/service/response.py @@ -17,6 +17,8 @@ class SyftResponseMessage(SyftBaseModel): require_api_update: bool = False def __getattr__(self, name: str) -> Any: + if name == "_bool": + return super().__getattr__(name) raise Exception( f"You have tried accessing `{name}` on a {type(self).__name__} with message: {self.message}" ) From 41f3835d621b50e5f2e7f1d676e4942d6300e03f Mon Sep 17 00:00:00 2001 From: teo Date: Wed, 22 May 2024 14:59:23 +0300 Subject: [PATCH 3/3] fix display issue --- packages/syft/src/syft/service/response.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/syft/src/syft/service/response.py b/packages/syft/src/syft/service/response.py index 69e4b02c836..06fefe4e50e 100644 --- a/packages/syft/src/syft/service/response.py +++ b/packages/syft/src/syft/service/response.py @@ -4,6 +4,7 @@ from typing import Any # third party +from IPython.display import display from result import Err # relative @@ -17,8 +18,22 @@ class SyftResponseMessage(SyftBaseModel): require_api_update: bool = False def __getattr__(self, name: str) -> Any: - if name == "_bool": + if name in [ + "_bool", + # "_repr_html_", + # "message", + # 'require_api_update', + # '__bool__', + # '__eq__', + # '__repr__', + # '__str__', + # '_repr_html_class_', + # '_repr_html_', + "_ipython_canary_method_should_not_exist_", + "_ipython_display_", + ] or name.startswith("_repr"): return super().__getattr__(name) + display(self) raise Exception( f"You have tried accessing `{name}` on a {type(self).__name__} with message: {self.message}" )