Skip to content

Commit

Permalink
updated node values after settings update
Browse files Browse the repository at this point in the history
  • Loading branch information
teo-milea committed May 22, 2024
1 parent 68d9380 commit 8b5d215
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/syft/src/syft/node/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 8b5d215

Please sign in to comment.