nvflare.apis.dxo module
- class DXO(data_kind: str, data: dict, meta: dict | None = None)[source]
Bases:
objectInit the DXO.
The Data Exchange Object standardizes the data passed between communicating parties.
- Parameters:
data_kind – kind of data
data – clear-text data
meta – None or dict for any additional properties
- to_file(file_path: str)[source]
Serialize the DXO object into the specified file.
- Parameters:
file_path – the file to save the serialized data (binary)
Returns: None
Convert the DXO object into Shareable.
- Returns:
Shareable object.
- class DataKind(value)[source]
Bases:
str,EnumAn enumeration.
- ANALYTIC = 'ANALYTIC'
- APP_DEFINED = 'APP_DEFINED'
- COLLECTION = 'COLLECTION'
- FL_MODEL = 'FL_MODEL'
- METRICS = 'METRICS'
- PSI = 'PSI'
- STATISTICS = 'STATISTICS'
- WEIGHTS = 'WEIGHTS'
- WEIGHT_DIFF = 'WEIGHT_DIFF'
- from_bytes(data: bytes) DXO[source]
Convert the data bytes into DXO object.
- Parameters:
data – a bytes object
- Returns:
an object loaded by FOBS from data
- from_file(file_path: str) DXO[source]
Read serialized data from the specified file and deserialize into DXO object.
- Parameters:
file_path – the file that has serialized DXO data.
Returns: DXO object
Notes: the data in the file must be generated by fobs.dumpf() on a DXO object.
Convert Shareable into a DXO object.
- Parameters:
s – Shareable object
- Returns:
DXO object.
- get_leaf_dxos(dxo: ~nvflare.apis.dxo.DXO, root_name: str = '') -> (<class 'dict'>, <class 'list'>)[source]
Traverse the specified dxo tree and return all leaf DXOs. The input dxo is a simple DXO or a collection DXO as a dict of DXOs.
- Parameters:
dxo – the DXO object to be traversed
root_name – the root name of the DXO
Returns: a dict of dxo_path => DXO object. The dxo path is the full path from the root to the leaf node, concatenation of all node names, separated by dots. A list of errors encountered during traversing.