Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove presently unused on_conclude_round from Strategy #483

Merged
merged 1 commit into from
Nov 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions doc/source/implementing-strategies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ The strategy abstraction defines a few abstract methods that need to be implemen
@abstractmethod
def evaluate(self, weights: Weights) -> Optional[Tuple[float, float]]:

@abstractmethod
def on_conclude_round(
self, rnd: int, loss: Optional[float], acc: Optional[float]
) -> bool:

Creating a new strategy means implmenting a new :code:`class` derived from the abstract base class :code:`Strategy` which provides implementations for the previously shown abstract methods:

.. code-block:: python
Expand All @@ -69,9 +64,6 @@ Creating a new strategy means implmenting a new :code:`class` derived from the a
def evaluate(self, weights):
# Your implementation here

def on_conclude_round(self, rnd, loss, acc):
# Your implementation here

The following sections describe each of those methods in detail.

The :code:`on_configure_fit` method
Expand All @@ -98,8 +90,3 @@ The :code:`evaluate` method
---------------------------

*coming soon*

The :code:`on_conclude_round` method
------------------------------------

*coming soon*
7 changes: 0 additions & 7 deletions src/py/flwr/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ def fit(self, num_rounds: int) -> History:
rnd=current_round, loss=cast(float, loss_fed)
)

# Conclude round
loss = res_cen[0] if res_cen is not None else None
acc = res_cen[1] if res_cen is not None else None
should_continue = self.strategy.on_conclude_round(current_round, loss, acc)
if not should_continue:
break

# Send shutdown signal to all clients
all_clients = self._client_manager.all()
_ = shutdown(clients=[all_clients[k] for k in all_clients.keys()])
Expand Down
6 changes: 0 additions & 6 deletions src/py/flwr/server/strategy/fedavg.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,3 @@ def on_aggregate_evaluate(
for _, evaluate_res in results
]
)

def on_conclude_round(
self, rnd: int, loss: Optional[float], acc: Optional[float]
) -> bool:
"""Always continue training."""
return True
6 changes: 0 additions & 6 deletions src/py/flwr/server/strategy/qffedavg.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,3 @@ def on_aggregate_evaluate(
for client, evaluate_res in results
]
)

def on_conclude_round(
self, rnd: int, loss: Optional[float], acc: Optional[float]
) -> bool:
"""Always continue training."""
return True
16 changes: 0 additions & 16 deletions src/py/flwr/server/strategy/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,3 @@ def evaluate(self, weights: Weights) -> Optional[Tuple[float, float]]:
Returns:
The evaluation result, usually a Tuple containing loss and accuracy.
"""

@abstractmethod
def on_conclude_round(
self, rnd: int, loss: Optional[float], acc: Optional[float]
) -> bool:
"""Conclude federated learning round and decide whether to continue or
not.

Arguments:
rnd: int. The current round of federated learning.
loss: Optional[float]. The loss of the global model weights.
acc: Optional[float]. The accuracy of the global model weights.

Returns:
A boolean indicating whether the server should continue or not.
"""