Authenticated Client Manager

Authenticated Client Manager#

class rizemind.authentication.authenticated_client_manager.AlwaysTrueCriterion[source]

Bases: Criterion

A criterion that marks all clients as eligible for sampling.

select(client: ClientProxy) bool[source]

Returns True for any client, marking it as eligible for sampling.

Parameters:

client – The client whose eligibility is being determined.

class rizemind.authentication.authenticated_client_manager.AndCriterion(criterion_a: Criterion | None, criterion_b: Criterion | None)[source]

Bases: Criterion

A criterion that performs logical AND operation on two criteria.

This criterion evaluates both provided criteria in parallel using a thread pool and returns True only if both criteria evaluate to True for a given client.

criterion_a

First criterion to evaluate. If None, defaults to AlwaysTrueCriterion.

Type:

flwr.server.criterion.Criterion

criterion_b

Second criterion to evaluate. If None, defaults to AlwaysTrueCriterion.

Type:

flwr.server.criterion.Criterion

criterion_a: Criterion
criterion_b: Criterion
select(client: ClientProxy) bool[source]

Evaluate both criteria and return True only if both pass.

The criteria are evaluated in parallel using a thread pool for efficiency. Any exceptions from either criterion will be propagated.

Parameters:

client – The client to evaluate against both criteria.

Returns:

True if both criteria evaluate to True, False otherwise.

class rizemind.authentication.authenticated_client_manager.AuthenticatedClientManager(base_manager: ClientManager, round_id: int, swarm: SupportsEthAccountStrategy)[source]

Bases: ClientManager

Wraps another ClientManager and injects authentication Criterion.

round_id

Current federated learning round identifier.

Type:

int

swarm

Current swarm.

Type:

rizemind.authentication.typing.SupportsEthAccountStrategy

all() dict[str, ClientProxy][source]

Get all registered clients.

Returns:

Dictionary mapping client IDs to their corresponding client proxies.

num_available() int[source]

Get the number of available clients.

Returns:

The total number of clients available in the base manager.

register(client: ClientProxy) bool[source]

Register a client with the base manager.

Parameters:

client – The client proxy to register.

Returns:

True if registration was successful, False otherwise.

round_id: int
sample(num_clients: int, min_num_clients: int | None = None, criterion: Any | None = None) list[ClientProxy][source]

Sample clients with authentication checks.

Adds authentication criterion to ensure only clients that can train in the current round are selected. The authentication criterion is combined with any provided criterion using logical AND.

Parameters:
  • num_clients – Number of clients to sample.

  • min_num_clients – Minimum number of clients required. Defaults to None.

  • criterion – Additional criterion to apply. Defaults to None.

Returns:

List of authenticated client proxies that meet all criteria.

swarm: SupportsEthAccountStrategy
unregister(client: ClientProxy) None[source]

Unregister a client from the base manager.

Parameters:

client – The client proxy to unregister.

wait_for(num_clients: int, timeout: int) bool[source]

Wait for a minimum number of clients to be available.

Parameters:
  • num_clients – Minimum number of clients to wait for.

  • timeout – Maximum time to wait in seconds.

Returns:

True if the required number of clients became available within the timeout, False otherwise.