Skip to content

Commit

Permalink
Move workspace setup inside constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanTingHsieh committed Jan 23, 2024
1 parent d5c7d4e commit 2348139
Showing 1 changed file with 11 additions and 11 deletions.
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):
# run_status = self.simulator_run_main()
try:
run_status = mpm.run(
Expand Down

0 comments on commit 2348139

Please sign in to comment.