Skip to content

Commit

Permalink
Add the app_custom_folder in a proper way.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhwen committed Aug 12, 2024
1 parent 23182f7 commit 09f6fc8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 0 additions & 4 deletions nvflare/private/fed/app/client/sub_worker_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import copy
import logging
import os
import sys
import threading
import time

Expand Down Expand Up @@ -310,9 +309,6 @@ def stop(self):

def main(args):
workspace = Workspace(args.workspace, args.client_name)
app_custom_folder = workspace.get_app_custom_dir(args.job_id)
if os.path.isdir(app_custom_folder) and app_custom_folder not in sys.path:
sys.path.append(app_custom_folder)
configure_logging(workspace)

fobs_initialize(workspace=workspace, job_id=args.job_id)
Expand Down
6 changes: 5 additions & 1 deletion nvflare/private/fed/app/simulator/simulator_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,10 @@ def do_one_task(self, client, num_of_threads, gpu, lock, timeout=60.0, task_name
name=ConfigVarName.DECOMPOSER_MODULE, conf=SystemConfigs.RESOURCES_CONF
)

app_custom_folder = Workspace(root_dir=client_workspace, site_name="mgh").get_app_custom_dir(
SimulatorConstants.JOB_NAME
)

command = (
sys.executable
+ " -m nvflare.private.fed.app.simulator.simulator_worker -o "
Expand Down Expand Up @@ -698,7 +702,7 @@ 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()
new_env["PYTHONPATH"] = os.pathsep.join(self._get_new_sys_path())
new_env["PYTHONPATH"] = os.pathsep.join(self._get_new_sys_path()) + os.pathsep + app_custom_folder

_ = subprocess.Popen(shlex.split(command, True), preexec_fn=os.setsid, env=new_env)

Expand Down

0 comments on commit 09f6fc8

Please sign in to comment.