nvflare.app_opt.xgboost.histogram_based_v2.mock.mock_data_converter module

class MockDataConverter[source]

Bases: DataConverter

decode_aggregation_context(buffer: bytes, fl_ctx: FLContext) AggregationContext[source]

Decode the buffer to extract aggregation context info

Parameters:
  • buffer – buffer to be decoded

  • fl_ctx – FLContext info

Returns: if the buffer contains aggregation context, return an AggregationContext object;

otherwise, return None

decode_gh_pairs(buffer: bytes, fl_ctx: FLContext) List[Tuple[int, int]][source]

Decode the buffer to extract (g, h) pairs.

Parameters:
  • buffer – the buffer to be decoded

  • fl_ctx – FLContext info

Returns: if the buffer contains (g, h) pairs, return a tuple of (g_numbers, h_numbers);

otherwise, return None

encode_aggregation_result(aggr_results: Dict[int, List[FeatureAggregationResult]], fl_ctx: FLContext) bytes[source]

Encode an individual rank’s aggr result to a buffer based on XGB data structure

Parameters:
  • aggr_results – aggregation result for all features and all groups from all clients group_id => list of feature aggr results

  • fl_ctx – FLContext info

Returns: a buffer of bytes

class TupleAggregator[source]

Bases: Aggregator

add(a, b)[source]
decode_msg(msg: bytes) dict[source]