flip.nvflare.components.pt_model_locator

Classes

PTModelLocator

InitialPTModelLocator

EvaluationPTModelLocator

EvaluationModelLocator

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:
  1. <app_dir>/custom/<checkpoint> — a checkpoint bundled in the app. Used by the local simulator (which copies the .pt into custom/) and any legacy bundling.

  2. <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/src shared 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.ModelLocator

Locate uploaded checkpoint(s) for Client-API evaluation under the standard ModelLocator interface.

Unlike EvaluationPTModelLocator — which returns a single DataKind.COLLECTION DXO for the bespoke ModelEval controller — this exposes the stock get_model_names + locate_model(model_name, fl_ctx) contract so it drives NVFLARE’s stock CrossSiteModelEval validate workflow directly. Each model named in config.json['models'] becomes one DataKind.WEIGHTS DXO that the server broadcasts to clients as a single FLModel for the Client-API is_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 as EvaluationPTModelLocator). Clients never read the .pt files — they receive the weights over the validate task. model_id is resolved lazily from meta.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 into self.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