Skip to content

Commit

Permalink
Merge pull request #289 from VectorInstitute/dbe/fixing_infinite_base…
Browse files Browse the repository at this point in the history
…_server_test

Fixing infinite base server test
  • Loading branch information
scarere authored Nov 18, 2024
2 parents c3e96ff + dfc9a6a commit 593331d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion fl4health/server/base_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ def evaluate_round(
"eval_round_end": str(end_time),
}
dummy_params = Parameters([], "None")
config = self.strategy.configure_fit(server_round, dummy_params, self._client_manager)[0][1].config
config = self.strategy.configure_evaluate(server_round, dummy_params, self._client_manager)[0][
1
].config
if config.get("local_epochs", None) is not None:
report_data["fit_epoch"] = server_round * config["local_epochs"]
elif config.get("local_steps", None) is not None:
Expand Down
8 changes: 6 additions & 2 deletions tests/server/test_base_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from flwr.common.parameter import ndarrays_to_parameters
from flwr.server.client_proxy import ClientProxy
from flwr.server.history import History
from flwr.server.strategy import FedAvg
from freezegun import freeze_time

from fl4health.checkpointing.checkpointer import BestLossTorchCheckpointer
Expand Down Expand Up @@ -247,9 +248,12 @@ def test_metrics_reporter_evaluate_round(mock_evaluate_round: Mock) -> None:
test_metrics_aggregated,
(None, None),
)

client_manager = SimpleClientManager()
client_manager.register(CustomClientProxy("test_id", 1))
reporter = JsonReporter()
fl_server = FlServer(SimpleClientManager(), reporters=[reporter])
fl_server = FlServer(
client_manager, reporters=[reporter], strategy=FedAvg(min_evaluate_clients=1, min_available_clients=1)
)
fl_server.evaluate_round(test_round, None)

metrics_to_assert = {
Expand Down

0 comments on commit 593331d

Please sign in to comment.