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

[2.4] Move workspace setup inside constructor #2308

Merged
merged 1 commit into from
Jan 24, 2024
Merged
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
22 changes: 11 additions & 11 deletions nvflare/private/fed/app/simulator/simulator_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ def __init__(

self.clients_created = 0

running_dir = os.getcwd()
if self.workspace is None:
self.workspace = "simulator_workspace"
self.logger.warn(
f"Simulator workspace is not provided. Set it to the default location:"
f" {os.path.join(running_dir, self.workspace)}"
)
self.workspace = os.path.join(running_dir, self.workspace)

def _generate_args(
self, job_folder: str, workspace: str, clients=None, n_clients=None, threads=None, gpu=None, max_clients=100
):
Expand All @@ -110,15 +119,6 @@ def _generate_args(
return args

def setup(self):
running_dir = os.getcwd()
if self.workspace is None:
self.workspace = "simulator_workspace"
self.logger.warn(
f"Simulator workspace is not provided. Set it to the default location:"
f" {os.path.join(running_dir, self.workspace)}"
)
self.workspace = os.path.join(running_dir, self.workspace)

self.args = self._generate_args(
self.job_folder, self.workspace, self.clients, self.n_clients, self.threads, self.gpu, self.max_clients
)
Expand Down Expand Up @@ -348,7 +348,7 @@ def run(self):
try:
manager = Manager()
return_dict = manager.dict()
process = Process(target=self.run_processs, args=(return_dict,))
process = Process(target=self.run_process, args=(return_dict,))
process.start()
process.join()
run_status = self._get_return_code(return_dict, process, self.workspace)
Expand Down Expand Up @@ -380,7 +380,7 @@ def _get_return_code(self, return_dict, process, workspace):
self.logger.info(f"return_code from process.exitcode: {return_code}")
return return_code

def run_processs(self, return_dict):
def run_process(self, return_dict):
YuanTingHsieh marked this conversation as resolved.
Show resolved Hide resolved
# run_status = self.simulator_run_main()
try:
run_status = mpm.run(
Expand Down