From 188adffb8acc2c444c5a97a0d48b1e56634005f1 Mon Sep 17 00:00:00 2001 From: refai06 Date: Thu, 17 Oct 2024 14:07:38 +0530 Subject: [PATCH] comments update Signed-off-by: refai06 --- .../experimental/component/aggregator/aggregator.py | 9 +++++---- .../component/collaborator/collaborator.py | 8 +++++--- openfl/experimental/interface/participants.py | 12 ++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/openfl/experimental/component/aggregator/aggregator.py b/openfl/experimental/component/aggregator/aggregator.py index bba3969008..080190ac64 100644 --- a/openfl/experimental/component/aggregator/aggregator.py +++ b/openfl/experimental/component/aggregator/aggregator.py @@ -109,15 +109,17 @@ def __initialize_private_attributes(self, kwargs: Dict) -> None: self.__private_attrs = self.__private_attrs_callable(**kwargs) def __set_private_attrs_to_clone(self, clone: Any) -> None: - """Set private_attrs to clone as attributes.""" + """Set private_attrs of Aggregator as attributes of FLSpec clone""" if len(self.__private_attrs) > 0: for name, attr in self.__private_attrs.items(): setattr(clone, name, attr) def __delete_private_attrs_from_clone(self, clone: Any, replace_str: str = None) -> None: """ - Remove aggregator private attributes from FLSpec clone before - transition from Aggregator step to collaborator steps. + Remove aggregator private attributes from FLSpec clone + before transition from aggregator step to collaborator steps. + Instead of removing private attributes this method can also replace + private attributes with a string (required in checkpointing) """ # Update aggregator private attributes by taking latest # parameters from clone, then delete attributes from clone. @@ -363,7 +365,6 @@ def do_task(self, f_name: str) -> Any: f_name = f.__name__ self.flow._display_transition_logs(f, parent_func) - # Transition check if aggregator_to_collaborator(f, parent_func): # Transition encountered, break the loop diff --git a/openfl/experimental/component/collaborator/collaborator.py b/openfl/experimental/component/collaborator/collaborator.py index 527d7ee940..d8e8a7fcd7 100644 --- a/openfl/experimental/component/collaborator/collaborator.py +++ b/openfl/experimental/component/collaborator/collaborator.py @@ -67,7 +67,7 @@ def __initialize_private_attributes(self, kwargs: Dict) -> None: self.__private_attrs = self.__private_attrs_callable(**kwargs) def __set_private_attrs_to_clone(self, clone: Any) -> None: - """Set private_attrs to clone as attributes. + """Set private_attrs of Collaborator as attributes of FLSpec clone. Args: clone (FLSpec): Clone to which private attributes are to be @@ -82,8 +82,10 @@ def __set_private_attrs_to_clone(self, clone: Any) -> None: def __delete_private_attrs_from_clone(self, clone: Any, replace_str: str = None) -> None: """ - Remove aggregator private attributes from FLSpec clone before - transition from Aggregator step to collaborator steps + Remove collaborator private attributes from FLSpec clone + before transition from Collaborator step to aggregator steps. + Instead of removing private attributes this method can also replace + private attributes with a string (required in checkpointing) Args: clone (FLSpec): Clone from which private attributes are to be diff --git a/openfl/experimental/interface/participants.py b/openfl/experimental/interface/participants.py index 9881cc017f..f9ac7f5e93 100644 --- a/openfl/experimental/interface/participants.py +++ b/openfl/experimental/interface/participants.py @@ -43,16 +43,16 @@ def name(self, name: str): self._name = name def get_name(self) -> str: - """Gets the name of the aggregator/collaborator. + """Gets the name of Participant (aggregator or collaborator). Returns: - str: The name of the aggregator/collaborator. + str: The name of the aggregator or collaborator. """ return self._name def initialize_private_attributes(self, private_attrs: Dict[Any, Any] = None) -> None: - """Initialize private attributes of aggregator/collaborator by invoking the - callable specified by user.""" + """Initialize private attributes of Participant (aggregator or collaborator) + by invoking the callable specified by user.""" if self.private_attributes_callable is not None: self.private_attributes = self.private_attributes_callable(**self.kwargs) elif private_attrs: @@ -60,7 +60,7 @@ def initialize_private_attributes(self, private_attrs: Dict[Any, Any] = None) -> def _set_private_attrs_to_clone(self, clone: Any) -> None: """Set private attributes to FLSpec clone before - transitioning from Aggregator step to collaborator steps. + transitioning from aggregator to collaborator or vice versa Args: clone (Any): The clone to set attributes to. @@ -71,7 +71,7 @@ def _set_private_attrs_to_clone(self, clone: Any) -> None: def _delete_private_attrs_from_clone(self, clone: Any) -> None: """Remove private attributes from FLSpec clone before - transition + transitioning from collaborator to aggregator or vice versa Args: clone (Any): The clone to remove attributes from.