From 23182f7eeeb29470722c5d267b52a5377ae7a972 Mon Sep 17 00:00:00 2001 From: Yuhong Wen Date: Mon, 12 Aug 2024 12:00:33 -0400 Subject: [PATCH] Changed back the workspace.get_client_custom_dir(), fixed the sub_worker_process app_custom_folder. --- nvflare/apis/workspace.py | 4 ++-- nvflare/fuel/hci/client/config.py | 6 ++++++ nvflare/private/fed/app/client/sub_worker_process.py | 2 +- nvflare/private/fed/utils/fed_utils.py | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/nvflare/apis/workspace.py b/nvflare/apis/workspace.py index efff6fefaa..44e821c45d 100644 --- a/nvflare/apis/workspace.py +++ b/nvflare/apis/workspace.py @@ -164,8 +164,8 @@ def get_job_meta_path(self, job_id: str) -> str: def get_site_privacy_file_path(self): return self.get_file_path_in_site_config(WorkspaceConstants.PRIVACY_CONFIG) - def get_client_custom_dir(self, job_id: str) -> str: - return os.path.join(self.get_app_dir(job_id), WorkspaceConstants.CUSTOM_FOLDER_NAME) + def get_client_custom_dir(self) -> str: + return os.path.join(self.get_site_config_dir(), WorkspaceConstants.CUSTOM_FOLDER_NAME) def get_stats_pool_summary_path(self, job_id: str, prefix=None) -> str: file_name = WorkspaceConstants.STATS_POOL_SUMMARY_FILE_NAME diff --git a/nvflare/fuel/hci/client/config.py b/nvflare/fuel/hci/client/config.py index 97559ac1fc..e8f86a6742 100644 --- a/nvflare/fuel/hci/client/config.py +++ b/nvflare/fuel/hci/client/config.py @@ -11,7 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import os import re +import sys from nvflare.apis.workspace import Workspace from nvflare.fuel.common.excepts import ConfigError @@ -37,6 +39,10 @@ def __init__(self, workspace: Workspace): base_pkgs = FL_PACKAGES module_names = FL_MODULES + custom_dir = workspace.get_client_custom_dir() + if os.path.isdir(custom_dir): + sys.path.append(custom_dir) + admin_config_file_path = workspace.get_admin_startup_file_path() config_files = [admin_config_file_path] resources_file_path = workspace.get_resources_file_path() diff --git a/nvflare/private/fed/app/client/sub_worker_process.py b/nvflare/private/fed/app/client/sub_worker_process.py index 4e5e2970f9..e0d5711ee4 100644 --- a/nvflare/private/fed/app/client/sub_worker_process.py +++ b/nvflare/private/fed/app/client/sub_worker_process.py @@ -310,7 +310,7 @@ def stop(self): def main(args): workspace = Workspace(args.workspace, args.client_name) - app_custom_folder = workspace.get_client_custom_dir(args.job_id) + 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) diff --git a/nvflare/private/fed/utils/fed_utils.py b/nvflare/private/fed/utils/fed_utils.py index 28b6cdd205..5285a86238 100644 --- a/nvflare/private/fed/utils/fed_utils.py +++ b/nvflare/private/fed/utils/fed_utils.py @@ -210,7 +210,7 @@ def fobs_initialize(workspace: Workspace = None, job_id: str = None): def custom_fobs_initialize(workspace: Workspace = None, job_id: str = None): if workspace: - site_custom_dir = workspace.get_client_custom_dir(job_id) + site_custom_dir = workspace.get_client_custom_dir() decomposer_dir = os.path.join(site_custom_dir, ConfigVarName.DECOMPOSER_MODULE) if os.path.exists(decomposer_dir): register_custom_folder(decomposer_dir)