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 the need to create additional ports when running a job #3017

Merged
merged 2 commits into from
Oct 10, 2024
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
2 changes: 0 additions & 2 deletions nvflare/private/fed/app/simulator/simulator_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,6 @@ def simulator_run_main(self):
try:
self.create_clients()
self.server.engine.run_processes[SimulatorConstants.JOB_NAME] = {
RunProcessKey.LISTEN_PORT: None,
RunProcessKey.CONNECTION: None,
RunProcessKey.CHILD_PROCESS: None,
RunProcessKey.JOB_ID: SimulatorConstants.JOB_NAME,
RunProcessKey.PARTICIPANTS: self.server.engine.client_manager.clients,
Expand Down
4 changes: 0 additions & 4 deletions nvflare/private/fed/client/client_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from nvflare.apis.fl_constant import FLContextKey, MachineStatus, SystemComponents, WorkspaceConstants
from nvflare.apis.fl_context import FLContext, FLContextManager
from nvflare.apis.workspace import Workspace
from nvflare.fuel.utils.network_utils import get_open_ports
from nvflare.private.defs import ERROR_MSG_PREFIX, ClientStatusKey, EngineConstant
from nvflare.private.event import fire_event
from nvflare.private.fed.server.job_meta_validator import JobMetaValidator
Expand Down Expand Up @@ -161,15 +160,12 @@ def start_app(

self.logger.info("Starting client app. rank: {}".format(self.rank))

open_port = get_open_ports(1)[0]

server_config = list(self.client.servers.values())[0]
self.client_executor.start_app(
self.client,
job_id,
self.args,
app_custom_folder,
open_port,
allocated_resource,
token,
resource_manager,
Expand Down
6 changes: 0 additions & 6 deletions nvflare/private/fed/client/client_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def start_app(
job_id,
args,
app_custom_folder,
listen_port,
allocated_resource,
token,
resource_manager,
Expand All @@ -56,7 +55,6 @@ def start_app(
job_id: the job_id
args: admin command arguments for starting the FL client training
app_custom_folder: FL application custom folder
listen_port: port to listen the command.
allocated_resource: allocated resources
token: token from resource manager
resource_manager: resource manager
Expand Down Expand Up @@ -149,7 +147,6 @@ def start_app(
job_id,
args,
app_custom_folder,
listen_port,
allocated_resource,
token,
resource_manager: ResourceManagerSpec,
Expand All @@ -163,7 +160,6 @@ def start_app(
job_id: the job_id
args: admin command arguments for starting the worker process
app_custom_folder: FL application custom folder
listen_port: port to listen the command.
allocated_resource: allocated resources
token: token from resource manager
resource_manager: resource manager
Expand Down Expand Up @@ -208,8 +204,6 @@ def start_app(

with self.lock:
self.run_processes[job_id] = {
RunProcessKey.LISTEN_PORT: listen_port,
RunProcessKey.CONNECTION: None,
RunProcessKey.CHILD_PROCESS: process,
RunProcessKey.STATUS: ClientStatus.STARTING,
}
Expand Down
7 changes: 0 additions & 7 deletions nvflare/private/fed/server/server_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
from nvflare.fuel.f3.cellnet.defs import MessageHeaderKey
from nvflare.fuel.f3.cellnet.defs import ReturnCode as CellMsgReturnCode
from nvflare.fuel.utils.argument_utils import parse_vars
from nvflare.fuel.utils.network_utils import get_open_ports
from nvflare.fuel.utils.zip_utils import zip_directory_to_bytes
from nvflare.private.admin_defs import Message, MsgHeader
from nvflare.private.defs import CellChannel, CellMessageHeaderKeys, RequestHeader, TrainingTopic, new_cell_message
Expand Down Expand Up @@ -179,13 +178,11 @@ def start_app_on_server(self, run_number: str, job: Job = None, job_clients=None
if not isinstance(job, Job):
return "Must provide a job object to start the server app."

open_ports = get_open_ports(2)
self._start_runner_process(
self.args,
app_root,
run_number,
app_custom_folder,
open_ports,
job.job_id,
job_clients,
snapshot,
Expand Down Expand Up @@ -233,7 +230,6 @@ def _start_runner_process(
app_root,
run_number,
app_custom_folder,
open_ports,
job_id,
job_clients,
snapshot,
Expand All @@ -244,7 +240,6 @@ def _start_runner_process(
if app_custom_folder != "":
add_custom_dir_to_path(app_custom_folder, new_env)

listen_port = open_ports[1]
if snapshot:
restore_snapshot = True
else:
Expand Down Expand Up @@ -289,8 +284,6 @@ def _start_runner_process(

with self.lock:
self.run_processes[run_number] = {
RunProcessKey.LISTEN_PORT: listen_port,
RunProcessKey.CONNECTION: None,
RunProcessKey.CHILD_PROCESS: process,
RunProcessKey.JOB_ID: job_id,
RunProcessKey.PARTICIPANTS: job_clients,
Expand Down
2 changes: 0 additions & 2 deletions nvflare/private/fed/simulator/simulator_client_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def __init__(self, client, args, rank=0):
fl_ctx.set_prop(FLContextKey.SIMULATE_MODE, True, private=True, sticky=True)

self.client_executor.run_processes[SimulatorConstants.JOB_NAME] = {
RunProcessKey.LISTEN_PORT: None,
RunProcessKey.CONNECTION: None,
RunProcessKey.CHILD_PROCESS: None,
RunProcessKey.STATUS: ClientStatus.STARTED,
}
Expand Down
Loading