fedn.utils package

The utils package is responsible for providing utility functions for the FEDn framework. Such as logging, checksums and other model helper functions to aggregate models. THe helper functions is there to support aggregating various models from different ML frameworks, such as Tensorflow, PyTorch and Keras.

Subpackages

Submodules

fedn.utils.checksum module

fedn.utils.checksum.sha(fname)[source]

Calculate the sha256 checksum of a file. Used for computing checksums of compute packages.

Parameters:

fname (str) – The file path.

Returns:

The sha256 checksum.

Return type:

hashlib.sha256

fedn.utils.dispatcher module

class fedn.utils.dispatcher.Dispatcher(config, dir)[source]

Bases: object

Dispatcher class for compute packages.

Parameters:
  • config (dict) – The configuration.

  • dir (str) – The directory to dispatch to.

run_cmd(cmd_type)[source]

Run a command.

Parameters:

cmd_type (str) – The command type.

Returns:

fedn.utils.helpers module

fedn.utils.helpers.get_helper(helper_module_name)[source]

Return an instance of the helper class.

Parameters:

helper_module_name (str) – The name of the helper plugin module.

Returns:

A helper instance.

Return type:

class: fedn.utils.helpers.HelperBase

fedn.utils.helpers.save_metadata(metadata, filename)[source]

Save metadata to file.

Parameters:
  • metadata (dict) – The metadata to save.

  • filename (str) – The name of the file to save to.

fedn.utils.helpers.save_metrics(metrics, filename)[source]

Save metrics to file.

Parameters:
  • metrics (dict) – The metrics to save.

  • filename (str) – The name of the file to save to.

fedn.utils.logger module

fedn.utils.process module

fedn.utils.process.run_process(args, cwd)[source]

Run a process and log the output.

Parameters:
  • args (list) – The arguments to the process.

  • cwd (str) – The current working directory.

Returns: