diff --git a/packages/syft/src/syft/node/node.py b/packages/syft/src/syft/node/node.py index 53225a152c6..43bd2643fc7 100644 --- a/packages/syft/src/syft/node/node.py +++ b/packages/syft/src/syft/node/node.py @@ -21,6 +21,7 @@ from nacl.signing import SigningKey from result import Err from result import Result +from syft.types.syft_metaclass import Empty from typing_extensions import Self # relative @@ -92,7 +93,7 @@ from ..service.service import AbstractService from ..service.service import ServiceConfigRegistry from ..service.service import UserServiceConfigRegistry -from ..service.settings.settings import NodeSettings +from ..service.settings.settings import NodeSettings, NodeSettingsUpdate from ..service.settings.settings_service import SettingsService from ..service.settings.settings_stash import SettingsStash from ..service.sync.sync_service import SyncService @@ -120,7 +121,7 @@ from ..store.mongo_document_store import MongoStoreConfig from ..store.sqlite_document_store import SQLiteStoreClientConfig from ..store.sqlite_document_store import SQLiteStoreConfig -from ..types.syft_object import SYFT_OBJECT_VERSION_2 +from ..types.syft_object import SYFT_OBJECT_VERSION_2, PartialSyftObject from ..types.syft_object import SyftObject from ..types.uid import UID from ..util.experimental_flags import flags @@ -994,6 +995,13 @@ def remove_temp_dir(self) -> None: if rootdir.exists(): shutil.rmtree(rootdir, ignore_errors=True) + def update_self(self, settings): + updateable_attrs = NodeSettingsUpdate.model_fields.keys() - PartialSyftObject.model_fields.keys() + for attr_name in updateable_attrs: + attr = getattr(settings, attr_name) + if attr is not Empty: + setattr(self, attr_name, attr) + @property def settings(self) -> NodeSettings: settings_stash = SettingsStash(store=self.document_store) @@ -1006,14 +1014,11 @@ def settings(self) -> NodeSettings: ) if settings.is_ok() and len(settings.ok()) > 0: settings = settings.ok()[0] + self.update_self(settings) return settings @property def metadata(self) -> NodeMetadataV3: - name = "" - organization = "" - description = "" - show_warnings = self.enable_warnings settings_data = self.settings name = settings_data.name organization = settings_data.organization