nvflare.app_common.np.np_model_locator module

class NPModelLocator(model_dir='models', model_name: str | Dict[str, str] = 'server.npy')[source]

Bases: ModelLocator

The ModelLocator’s job is to find the models to be included for cross site evaluation located on server. This NPModelLocator finds and extracts “server” model that is saved during training.

Parameters:
  • model_dir (str) – Directory to look for models in. Defaults to “models”. Only used when model_name contains relative paths.

  • model_name (Union[str, Dict[str, str]]) –

    Name or path of the model(s). Defaults to “server.npy”. - If a string, treated as filename for the “server” model - If a dict, maps model identifiers to filenames/paths - Paths can be:

    • Relative: resolved as <run_dir>/<model_dir>/<model_name>

    • Absolute: used directly (e.g., “/path/to/pretrained.npy”)

SERVER_MODEL_NAME = 'server'
get_model_names(fl_ctx: FLContext) List[str][source]

Returns the list of model names that should be included from server in cross site validation.add()

Parameters:

fl_ctx (FLContext) – FL Context object.

Returns:

List of model names.

Return type:

List[str]

locate_model(model_name, fl_ctx: FLContext) DXO[source]

Locate a single model by its name.

Parameters:
  • model_name (str) – Name of the model.

  • fl_ctx (FLContext) – FL Context object.

Returns:

a DXO object

Return type:

DXO