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:
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.Otherwise read
fl_ctx.get_prop(FLContextKey.JOB_META)["custom_props"]["model_id"].Otherwise raise
ValueError— neither path produced a UUID.
Attributes
Functions
|
Return the |
|
Read |
|
Resolve the FLIP |
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_propsdict from the job’smeta.json, or{}if absent.NVFLARE sets
FLContextKey.JOB_METAwithsticky=False, so it’s only on the fl_ctx during the component-build phase — gone by the time controllers fire events. Fall back to readingmeta.jsonstraight 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.jsonfrom 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_idfor 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
fallbacknormeta.json’scustom_props.model_idholds a valid UUID.