fl4health.client_managers.base_sampling_manager module

class BaseFractionSamplingManager[source]

Bases: SimpleClientManager

Overrides the Simple Client Manager to Provide Fixed Sampling without replacement for Clients

sample(num_clients, min_num_clients=None, criterion=None)[source]

Sample a number of Flower ClientProxy instances.

Return type:

list[ClientProxy]

sample_all(min_num_clients=None, criterion=None)[source]

Samples ALL available clients

Parameters:
  • min_num_clients (int | None, optional) – minimum number of clients to wait to become available before selecting all available clients. Defaults to None.

  • criterion (Criterion | None, optional) – Criterion used to filter returned clients. If none, no filter is applied. Defaults to None.

Returns:

List of selected clients represented by ClientProxy objects.

Return type:

list[ClientProxy]

sample_fraction(sample_fraction, min_num_clients=None, criterion=None)[source]
Return type:

list[ClientProxy]

wait_and_filter(min_num_clients, criterion=None)[source]

Waits for min_num_clients to become available then select clients from those available and filter them based on the criterion provided. If min_num_clients is None, then it waits for at least 1 client to be available.

Parameters:
  • min_num_clients (int | None) – Number of clients to wait for before performing filtration.

  • criterion (Criterion | None, optional) – criterion used to filter available clients. Defaults to None.

Returns:

List of CIDs representing available and filtered clients.

Return type:

list[str]