Skip to content

Commit

Permalink
Fix client custom code
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanTingHsieh committed Apr 1, 2024
1 parent 5c40a07 commit c7f2e05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 3 additions & 7 deletions nvflare/private/fed/app/simulator/simulator_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,10 @@ def do_one_task(self, client, num_of_threads, gpu, lock, timeout=60.0, task_name
if gpu:
command += " --gpu " + str(gpu)
new_env = os.environ.copy()
# append custom to path_to_pass so won't affect sys.path
app_custom_folder = os.path.join(client_workspace, "custom")
path_to_pass = [p for p in sys.path]
path_to_pass.append(app_custom_folder)
if not path_to_pass[0]:
new_env["PYTHONPATH"] = os.pathsep.join(path_to_pass[1:])
if not sys.path[0]:
new_env["PYTHONPATH"] = os.pathsep.join(sys.path[1:])
else:
new_env["PYTHONPATH"] = os.pathsep.join(path_to_pass)
new_env["PYTHONPATH"] = os.pathsep.join(sys.path)
_ = subprocess.Popen(shlex.split(command, True), preexec_fn=os.setsid, env=new_env)

conn = self._create_connection(open_port, timeout=timeout)
Expand Down
2 changes: 2 additions & 0 deletions nvflare/private/fed/app/simulator/simulator_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ def main(args):
log_file = os.path.join(args.workspace, WorkspaceConstants.LOG_FILE_NAME)
add_logfile_handler(log_file)

app_custom_folder = os.path.join(args.workspace, "custom")
sys.path.append(app_custom_folder)
os.chdir(args.workspace)
fobs_initialize()
AuthorizationService.initialize(EmptyAuthorizer())
Expand Down

0 comments on commit c7f2e05

Please sign in to comment.