Skip to content

Commit

Permalink
comments update
Browse files Browse the repository at this point in the history
Signed-off-by: refai06 <[email protected]>
  • Loading branch information
refai06 committed Oct 17, 2024
1 parent fbeb05b commit 188adff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
9 changes: 5 additions & 4 deletions openfl/experimental/component/aggregator/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions openfl/experimental/component/collaborator/collaborator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions openfl/experimental/interface/participants.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,24 @@ 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:
self.private_attributes = private_attrs

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.
Expand All @@ -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.
Expand Down

0 comments on commit 188adff

Please sign in to comment.