flip.nvflare.runtime

Runtime resolution of FLIP-specific job parameters from NVFLARE’s job metadata.

The FLIP-API hands job-scoped values (model_id, optionally participating_clients) to NVFLARE via meta.json’s custom_props dict. FLIP components fetch these at first use via get_flip_model_id() rather than requiring them as __init__ arguments — this lets the Python FlipFedAvgRecipe build a real FedJob (no UUID known yet) that runs identically in SimEnv, PocEnv, ProdEnv, or under the FLIP-API.

Resolution order, given a component that also accepts a legacy model_id constructor arg:

  1. If the constructor arg is a real UUID (e.g. the FLIP-API substituted {model_id} into the JSON config before NVFLARE loaded it), use it.

  2. Otherwise read fl_ctx.get_prop(FLContextKey.JOB_META)["custom_props"]["model_id"].

  3. Otherwise raise ValueError — neither path produced a UUID.

Attributes

FLIP_CUSTOM_PROPS_KEY

FLIP_MODEL_ID_KEY

FLIP_PARTICIPATING_CLIENTS_KEY

Functions

get_job_custom_props(→ dict[str, Any])

Return the custom_props dict from the job's meta.json, or {} if absent.

_load_meta_from_workspace(→ dict[str, Any] | None)

Read meta.json from the run dir if the FLContext doesn't carry it.

get_flip_model_id(→ str)

Resolve the FLIP model_id for the current job.

Module Contents

flip.nvflare.runtime.FLIP_CUSTOM_PROPS_KEY = 'custom_props'
flip.nvflare.runtime.FLIP_MODEL_ID_KEY = 'model_id'
flip.nvflare.runtime.FLIP_PARTICIPATING_CLIENTS_KEY = 'participating_clients'
flip.nvflare.runtime.get_job_custom_props(fl_ctx: nvflare.apis.fl_context.FLContext) dict[str, Any]

Return the custom_props dict from the job’s meta.json, or {} if absent.

NVFLARE sets FLContextKey.JOB_META with sticky=False, so it’s only on the fl_ctx during the component-build phase — gone by the time controllers fire events. Fall back to reading meta.json straight from the workspace’s run dir.

flip.nvflare.runtime._load_meta_from_workspace(fl_ctx: nvflare.apis.fl_context.FLContext) dict[str, Any] | None

Read meta.json from the run dir if the FLContext doesn’t carry it.

flip.nvflare.runtime.get_flip_model_id(fl_ctx: nvflare.apis.fl_context.FLContext, fallback: str | None = None) str

Resolve the FLIP model_id for the current job.

Parameters:
  • fl_ctx – The NVFLARE FLContext.

  • fallback – Value passed to the component’s __init__ (legacy path). If this is a valid UUID it is returned as-is; otherwise it’s ignored.

Returns:

A UUID string.

Raises:

ValueError – If neither fallback nor meta.json’s custom_props.model_id holds a valid UUID.