Skip to content

Commit

Permalink
fix simulator missing client heartbeat call. (#1196)
Browse files Browse the repository at this point in the history
  • Loading branch information
yhwen authored Jan 10, 2023
1 parent 01f3bb4 commit a15ddf4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nvflare/private/fed/app/deployer/simulator_deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from nvflare.private.fed.client.admin_msg_sender import AdminMessageSender
from nvflare.private.fed.client.client_req_processors import ClientRequestProcessors
from nvflare.private.fed.client.fed_client import FederatedClient
from nvflare.private.fed.simulator.simulator_client_engine import SimulatorClientEngine
from nvflare.private.fed.simulator.simulator_client_engine import SimulatorClientEngine, SimulatorParentClientEngine
from nvflare.private.fed.simulator.simulator_server import SimulatorServer

from .base_client_deployer import BaseClientDeployer
Expand Down Expand Up @@ -69,6 +69,8 @@ def create_fl_client(self, client_name, args):
deployer.build(build_ctx)
federated_client = deployer.create_fed_client(args)

client_engine = SimulatorParentClientEngine()
federated_client.set_client_engine(client_engine)
federated_client.register()
federated_client.start_heartbeat()
federated_client.run_manager = None
Expand Down
9 changes: 9 additions & 0 deletions nvflare/private/fed/simulator/simulator_client_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from nvflare.apis.shareable import ReservedHeaderKey, Shareable
from nvflare.private.fed.client.client_engine import ClientEngine
from nvflare.private.fed.simulator.simulator_const import SimulatorConstants


class SimulatorClientEngine(ClientEngine):
Expand All @@ -26,3 +27,11 @@ def send_aux_command(self, shareable: Shareable, job_id):
with run_manager.new_context() as fl_ctx:
topic = shareable.get_header(ReservedHeaderKey.TOPIC)
return run_manager.dispatch(topic=topic, request=shareable, fl_ctx=fl_ctx)


class SimulatorParentClientEngine(ClientEngine):
def __init__(self):
pass

def get_all_job_ids(self):
return [SimulatorConstants.JOB_NAME]

0 comments on commit a15ddf4

Please sign in to comment.