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

[2.5] Fix external configurator #3159

Merged
merged 3 commits into from
Jan 22, 2025
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
24 changes: 21 additions & 3 deletions nvflare/app_common/widgets/external_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
from typing import List

from nvflare.apis.event_type import EventType
from nvflare.apis.fl_constant import FLMetaKey
from nvflare.apis.fl_constant import FLMetaKey, SecureTrainConst
from nvflare.apis.fl_context import FLContext
from nvflare.client.config import write_config_to_file
from nvflare.client.constants import CLIENT_API_CONFIG
from nvflare.fuel.data_event.utils import get_scope_property
from nvflare.fuel.utils.attributes_exportable import ExportMode, export_components
from nvflare.fuel.utils.validation_utils import check_object_type
from nvflare.widgets.widget import Widget
Expand Down Expand Up @@ -47,8 +48,19 @@ def __init__(
def handle_event(self, event_type: str, fl_ctx: FLContext):
if event_type == EventType.ABOUT_TO_START_RUN:
components_data = self._export_all_components(fl_ctx)
components_data[FLMetaKey.SITE_NAME] = fl_ctx.get_identity_name()

site_name = fl_ctx.get_identity_name()
auth_token = get_scope_property(scope_name=site_name, key=FLMetaKey.AUTH_TOKEN, default="NA")
signature = get_scope_property(scope_name=site_name, key=FLMetaKey.AUTH_TOKEN_SIGNATURE, default="NA")

components_data[FLMetaKey.SITE_NAME] = site_name
components_data[FLMetaKey.JOB_ID] = fl_ctx.get_job_id()
components_data[FLMetaKey.AUTH_TOKEN] = auth_token
components_data[FLMetaKey.AUTH_TOKEN_SIGNATURE] = signature

conn_sec = get_scope_property(site_name, SecureTrainConst.CONNECTION_SECURITY)
if conn_sec:
components_data[SecureTrainConst.CONNECTION_SECURITY] = conn_sec

config_file_path = self._get_external_config_file_path(fl_ctx)
write_config_to_file(config_data=components_data, config_file_path=config_file_path)
Expand All @@ -65,5 +77,11 @@ def _export_all_components(self, fl_ctx: FLContext) -> dict:
engine = fl_ctx.get_engine()
all_components = engine.get_all_components()
components = {i: all_components.get(i) for i in self._component_ids}
reserved_keys = [FLMetaKey.SITE_NAME, FLMetaKey.JOB_ID]
reserved_keys = [
FLMetaKey.SITE_NAME,
FLMetaKey.JOB_ID,
FLMetaKey.AUTH_TOKEN,
FLMetaKey.AUTH_TOKEN_SIGNATURE,
SecureTrainConst.CONNECTION_SECURITY,
]
return export_components(components=components, reserved_keys=reserved_keys, export_mode=ExportMode.PEER)
Loading