flip.nvflare.components.pt_model_locator
Classes
Locate uploaded checkpoint(s) for Client-API evaluation under the standard ModelLocator interface. |
Module Contents
- class flip.nvflare.components.pt_model_locator.PTModelLocator(exclude_vars=None, model=None)
Bases:
nvflare.app_common.abstract.model_locator.ModelLocator- model = None
- exclude_vars = None
- get_model_names(fl_ctx: nvflare.apis.fl_context.FLContext) list[str]
- locate_model(model_name: str, fl_ctx: nvflare.apis.fl_context.FLContext) nvflare.apis.dxo.DXO | None
- class flip.nvflare.components.pt_model_locator.InitialPTModelLocator(exclude_vars=None, model=None)
Bases:
nvflare.app_common.abstract.model_locator.ModelLocator- model = None
- exclude_vars = None
- get_model_names(fl_ctx: nvflare.apis.fl_context.FLContext) list[str]
- locate_model(model_name: str, fl_ctx: nvflare.apis.fl_context.FLContext) nvflare.apis.dxo.DXO | None
- class flip.nvflare.components.pt_model_locator.EvaluationPTModelLocator(exclude_vars=None, model_id: str = '')
Bases:
nvflare.app_common.abstract.model_locator.ModelLocator- models = None
- exclude_vars = None
- model_id = ''
- _resolve_checkpoint_path(fl_ctx: nvflare.apis.fl_context.FLContext, app_dir: str, name: str, model_checkpoint: str)
Locate a model checkpoint for server-side loading.
- Resolution order:
<app_dir>/custom/<checkpoint>— a checkpoint bundled in the app. Used by the local simulator (which copies the.ptintocustom/) and any legacy bundling.<SERVER_CHECKPOINT_ROOT>/<model_id>/<checkpoint>— the de-bundled checkpoint the FL API staged on the hub-local shared volume (production). Read straight from disk; the checkpoint is intentionally NOT shipped in the app bundle, so it never reaches the clients. This mirrors the Flower backend’s/app/srcshared mount.
Returns the resolved path, or
None(after logging an error) when neither exists.
- locate_model(fl_ctx: nvflare.apis.fl_context.FLContext) nvflare.apis.dxo.DXO | None
- class flip.nvflare.components.pt_model_locator.EvaluationModelLocator
Bases:
nvflare.app_common.abstract.model_locator.ModelLocatorLocate uploaded checkpoint(s) for Client-API evaluation under the standard ModelLocator interface.
Unlike
EvaluationPTModelLocator— which returns a singleDataKind.COLLECTIONDXO for the bespokeModelEvalcontroller — this exposes the stockget_model_names+locate_model(model_name, fl_ctx)contract so it drives NVFLARE’s stockCrossSiteModelEvalvalidate workflow directly. Each model named inconfig.json['models']becomes oneDataKind.WEIGHTSDXO that the server broadcasts to clients as a singleFLModelfor the Client-APIis_evaluate()path.The checkpoints are loaded server-side only — from the app’s
custom/directory when bundled (simulator / legacy bundling), else from the FL API’s de-bundled staging volume at<SERVER_CHECKPOINT_ROOT>/<model_id>/(production; same resolution order asEvaluationPTModelLocator). Clients never read the.ptfiles — they receive the weights over thevalidatetask.model_idis resolved lazily frommeta.json['custom_props'](recipe-built job types carry no component args).- models: dict | None = None
- _resolve_checkpoint_path(fl_ctx: nvflare.apis.fl_context.FLContext, app_dir: str, name: str, model_checkpoint: str)
Locate a checkpoint: bundled
custom/first, then the FL API’s shared staging volume.
- _load_models(fl_ctx: nvflare.apis.fl_context.FLContext) None
Read
config.json['models']and load each named checkpoint intoself.models.
- get_model_names(fl_ctx: nvflare.apis.fl_context.FLContext) list[str]
- locate_model(model_name: str, fl_ctx: nvflare.apis.fl_context.FLContext) nvflare.apis.dxo.DXO | None