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

keep the local resources for simulator #2730

Merged
merged 4 commits into from
Jul 30, 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
13 changes: 12 additions & 1 deletion nvflare/private/fed/app/simulator/simulator_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def setup(self):
for i in range(self.args.n_clients):
self.client_names.append("site-" + str(i + 1))

log_config_file_path = os.path.join(self.args.workspace, "startup", WorkspaceConstants.LOGGING_CONFIG)
log_config_file_path = os.path.join(self.args.workspace, "local", WorkspaceConstants.LOGGING_CONFIG)
if not os.path.isfile(log_config_file_path):
log_config_file_path = os.path.join(os.path.dirname(__file__), WorkspaceConstants.LOGGING_CONFIG)
logging.config.fileConfig(fname=log_config_file_path, disable_existing_loggers=False)
Expand Down Expand Up @@ -271,18 +271,29 @@ def _cleanup_workspace(self):
with tempfile.TemporaryDirectory() as temp_dir:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need L270 os.makedirs(self.simulator_root, exist_ok=True) in cleanup_workspace?

startup_dir = os.path.join(self.args.workspace, "startup")
temp_start_up = os.path.join(temp_dir, "startup")
local_dir = os.path.join(self.args.workspace, "local")
temp_local_dir = os.path.join(temp_dir, "local")
if os.path.exists(startup_dir):
shutil.move(startup_dir, temp_start_up)
if os.path.exists(local_dir):
shutil.move(local_dir, temp_local_dir)

if os.path.exists(self.simulator_root):
shutil.rmtree(self.simulator_root)

if os.path.exists(temp_start_up):
shutil.move(temp_start_up, startup_dir)
if os.path.exists(temp_local_dir):
shutil.move(temp_local_dir, local_dir)

def _setup_local_startup(self, log_config_file_path, workspace):
local_dir = os.path.join(workspace, "local")
startup = os.path.join(workspace, "startup")
os.makedirs(local_dir, exist_ok=True)
shutil.copyfile(log_config_file_path, os.path.join(local_dir, WorkspaceConstants.LOGGING_CONFIG))
workspace_local = os.path.join(self.simulator_root, "local")
if os.path.exists(workspace_local):
shutil.copytree(workspace_local, local_dir, dirs_exist_ok=True)
yhwen marked this conversation as resolved.
Show resolved Hide resolved
shutil.copytree(os.path.join(self.simulator_root, "startup"), startup)

def validate_job_data(self):
Expand Down
Loading