Skip to content

Commit

Permalink
refactor(framework) Improve DEBUG logs (#4865)
Browse files Browse the repository at this point in the history
  • Loading branch information
jafermarq authored Jan 28, 2025
1 parent 3e1cf76 commit a74697f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/py/flwr/server/driver/grpc_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from .driver import Driver

ERROR_MESSAGE_DRIVER_NOT_CONNECTED = """
[Driver] Error: Not connected.
[flwr-serverapp] Error: Not connected.
Call `connect()` on the `GrpcDriverStub` instance before calling any of the other
`GrpcDriverStub` methods.
Expand Down Expand Up @@ -102,7 +102,7 @@ def _connect(self) -> None:
)
self._grpc_stub = ServerAppIoStub(self._channel)
_wrap_stub(self._grpc_stub, self._retry_invoker)
log(DEBUG, "[Driver] Connected to %s", self._addr)
log(DEBUG, "[flwr-serverapp] Connected to %s", self._addr)

def _disconnect(self) -> None:
"""Disconnect from the ServerAppIo API."""
Expand All @@ -113,7 +113,7 @@ def _disconnect(self) -> None:
self._channel = None
self._grpc_stub = None
channel.close()
log(DEBUG, "[Driver] Disconnected")
log(DEBUG, "[flwr-serverapp] Disconnected")

def set_run(self, run_id: int) -> None:
"""Set the run."""
Expand Down
1 change: 1 addition & 0 deletions src/py/flwr/server/serverapp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def run_serverapp( # pylint: disable=R0914, disable=W0212, disable=R0915
# Pull ServerAppInputs from LinkState
req = PullServerAppInputsRequest()
res: PullServerAppInputsResponse = driver._stub.PullServerAppInputs(req)
log(DEBUG, "flwr-serverapp: PullServerAppInputs")
if not res.HasField("run"):
sleep(3)
run_status = None
Expand Down
6 changes: 4 additions & 2 deletions src/py/flwr/server/superlink/driver/serverappio_servicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,8 @@ def PullServerAppInputs(
) -> PullServerAppInputsResponse:
"""Pull ServerApp process inputs."""
log(DEBUG, "ServerAppIoServicer.PullServerAppInputs")
# Init access to LinkState and Ffs
# Init access to LinkState
state = self.state_factory.state()
ffs = self.ffs_factory.ffs()

# Lock access to LinkState, preventing obtaining the same pending run_id
with self.lock:
Expand All @@ -374,6 +373,9 @@ def PullServerAppInputs(
if run_id is None:
return PullServerAppInputsResponse()

# Init access to Ffs
ffs = self.ffs_factory.ffs()

# Retrieve Context, Run and Fab for the run_id
serverapp_ctxt = state.get_serverapp_context(run_id)
run = state.get_run(run_id)
Expand Down

0 comments on commit a74697f

Please sign in to comment.