nvflare.widgets.info_collector module

class GroupInfoCollector[source]

Bases: object

Records the information using a dict of dict.

Note

Key is group name and value is the information dictionary.

add_info(group_name: str, info: dict)[source]
set_info(group_name: str, info: dict)[source]
class InfoCollector[source]

Bases: Widget

A widget for information collection.

Note

self.categories structure:
category (dict)
group (dict)

key/value (dict)

CATEGORY_ERROR = 'error'
CATEGORY_STATS = 'stats'
CTX_KEY_STATS_COLLECTOR = 'info_collector.stats_collector'
EVENT_TYPE_GET_STATS = 'info_collector.get_stats'
add_error(group_name: str, key: str, err: str)[source]

Adds error information to error category.

Parameters:
  • group_name (str) – One level down category is called group

  • key (str) – The key to be recorded inside the dict.

  • err (str) – The error value to be put in.

add_info(category_name: str, group_name: str, key: str, value)[source]

Adds information to the specified category / group.

Parameters:
  • category_name (str) – The top level distinction is called category.

  • group_name (str) – One level down category is called group

  • key (str) – The key to be recorded inside the dict.

  • value (str) – The value to be recorded inside the dict.

get_category(category_name: str)[source]

Gets the category dict.

Parameters:

category_name (str) – The name of the category.

Returns:

A dictionary of specified category.

get_errors()[source]

Gets the error category information.

get_group(category_name: str, group_name: str)[source]

Gets the group dict.

Parameters:
  • category_name (str) – The name of the category.

  • group_name (str) – The name of the group_name.

Returns:

A dictionary of specified category/group.

get_run_stats() dict[source]

Gets status for this current run.

Returns:

A dictionary that contains the status for this run.

handle_event(event_type: str, fl_ctx: FLContext)[source]

Handles events.

Parameters:
  • event_type (str) – event type fired by workflow.

  • fl_ctx (FLContext) – FLContext information.

reset_all()[source]

Resets all information collected.

reset_category(category_name: str)[source]

Resets the specified category information collected.

Parameters:

category_name (str) – The name of the category.

reset_errors()[source]

Resets the error category information.

reset_group(category_name: str, group_name: str)[source]

Resets the specified category/group information collected.

Parameters:
  • category_name (str) – The name of the category.

  • group_name (str) – The name of the group_name.

set_info(category_name: str, group_name: str, info: dict)[source]

Sets information to the specified category / group.

Parameters:
  • category_name (str) – The top level distinction is called category.

  • group_name (str) – One level down category is called group

  • info (dict) – The dict to be recorded.

Note

This sets the entire dictionary vs add_info only add a key-value pair.