openfl.component.assigner.custom_assigner.Assigner

class openfl.component.assigner.custom_assigner.Assigner(*, assigner_function, aggregation_functions_by_task, authorized_cols, rounds_to_train)

Bases: object

Custom assigner class.

Class Attributes:
  • agg_functions_by_task (dict) – Dictionary mapping tasks to their respective aggregation functions.

  • agg_functions_by_task_name (dict) – Dictionary mapping task names to their respective aggregation functions.

  • authorized_cols (list of str) – List of authorized collaborators.

  • rounds_to_train (int) – Number of rounds to train.

  • all_tasks_for_round (defaultdict) – Dictionary mapping round numbers to tasks.

  • collaborators_for_task (defaultdict) – Dictionary mapping round numbers to collaborators for each task.

  • collaborator_tasks (defaultdict) – Dictionary mapping round numbers to tasks for each collaborator.

  • assigner_function (function) – Function to assign tasks to collaborators.

Methods

define_task_assignments

Define task assignments for each round and collaborator.

get_aggregation_type_for_task

Get the aggregation type for a specific task (from self.tasks).

get_all_tasks_for_round

Get all tasks for a specific round.

get_collaborators_for_task

Get collaborators for a specific task in a specific round.

get_tasks_for_collaborator

Get tasks for a specific collaborator in a specific round.

define_task_assignments()

Define task assignments for each round and collaborator.

This method uses the assigner function to assign tasks to collaborators for each round. It also maps tasks to their respective aggregation functions.

Abstract method.

Parameters:

None

Returns:

None

get_aggregation_type_for_task(task_name)

Get the aggregation type for a specific task (from self.tasks).

Parameters:

task_name (str) – Name of the task.

Returns:

function – Aggregation function for the task.

get_all_tasks_for_round(round_number)

Get all tasks for a specific round.

Currently all tasks are performed on each round, But there may be a reason to change this.

Parameters:

round_number (int) – Round number.

Returns:

list – List of all tasks for the specified round.

get_collaborators_for_task(task_name, round_number)

Get collaborators for a specific task in a specific round.

Abstract method.

Parameters:
  • task_name (str) – Name of the task.

  • round_number (int) – Round number.

Returns:

list – List of collaborators for the task in the specified round.

get_tasks_for_collaborator(collaborator_name, round_number)

Get tasks for a specific collaborator in a specific round.

Abstract method.

Parameters:
  • collaborator_name (str) – Name of the collaborator.

  • round_number (int) – Round number.

Returns:

list – List of tasks for the collaborator in the specified round.