Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Commit

Permalink
PB-402 Add helper func
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-Steiner committed Feb 12, 2020
1 parent 9d2a3ab commit 374d4ef
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions xain_fl/coordinator/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ def _handle_rendezvous(
)

logger.debug(
"Send RendezvousResponse",
reply=_RENDEZVOUSREPLY.values_by_number[reply].name,
"Send RendezvousResponse", reply=pb_enum_to_str(_RENDEZVOUSREPLY, reply)
)
return RendezvousResponse(reply=reply)

Expand Down Expand Up @@ -311,7 +310,7 @@ def _handle_heartbeat(
logger.debug(
"Heartbeat response",
participant_id=participant_id,
state=_STATE.values_by_number[state].name,
state=pb_enum_to_str(_STATE, state),
round=self.current_round,
current_participants_count=self.participants.len(),
)
Expand Down Expand Up @@ -417,3 +416,16 @@ def _handle_end_training_round(

logger.debug("Send EndTrainingRoundResponse", participant_id=participant_id)
return EndTrainingRoundResponse()


def pb_enum_to_str(pb_enum, member_value: int) -> str:
"""Return the human readable string of a enum member value.
Args:
pb_enum: The proto enum definition.
member_value: The enum member value.
Returns:
The human readable string of a enum member value.
"""
return pb_enum.values_by_number[member_value].name

0 comments on commit 374d4ef

Please sign in to comment.