nvflare.apis.dxo module

class DXO(data_kind: str, data: dict, meta: dict | None = None)[source]

Bases: object

Init 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

add_filter_history(filter_name: str | List[str])[source]
get_filter_history()[source]
get_meta_prop(key: str, default=None)[source]
get_meta_props()[source]
remove_meta_props(keys: List[str])[source]
set_meta_prop(key: str, value)[source]
to_bytes() bytes[source]

Serialize the DXO object into bytes.

Returns:

object serialized in bytes.

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

to_shareable() Shareable[source]

Convert the DXO object into Shareable.

Returns:

Shareable object.

update_meta_props(meta)[source]
update_shareable(s: Shareable) Shareable[source]
validate() str[source]
class DataKind[source]

Bases: object

ANALYTIC = 'ANALYTIC'
COLLECTION = 'COLLECTION'
FL_MODEL = 'FL_MODEL'
METRICS = 'METRICS'
PSI = 'PSI'
STATISTICS = 'STATISTICS'
WEIGHTS = 'WEIGHTS'
WEIGHT_DIFF = 'WEIGHT_DIFF'
class MetaKey[source]

Bases: FLMetaKey

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.

from_shareable(s: Shareable) DXO[source]

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.