nvflare.client.tracking module

class MLflowWriter[source]

Bases: object

MLflowWriter mimics the usage of MLflow.

Users can replace the import of MLflow with FLARE’s MLflowWriter. They would then use MLflowWriter the same as they would use MLflow. MLflowWriter will send log records to the FLARE system.

log_metric(key: str, value: float, step: int | None = None) None[source]

Log a metric under the current run.

Parameters:
  • key (str) – Metric name. This string may only contain alphanumerics, underscores (_), dashes (-), periods (.), spaces ( ), and slashes (/). All backend stores will support keys up to length 250, but some may support larger keys.

  • value (float) – Metric value. Note that some special values such as +/- Infinity may be replaced by other values depending on the store. For example, the SQLAlchemy store replaces +/- Infinity with max / min float values. All backend stores will support values up to length 5000, but some may support larger values.

  • step (int, optional) – Metric step. Defaults to zero if unspecified.

log_metrics(metrics: Dict[str, float], step: int | None = None) None[source]

Log multiple metrics for the current run.

Parameters:
  • metrics (dict) – Dictionary of metric_name: String -> value: Float. Note that some special values such as +/- Infinity may be replaced by other values depending on the store. For example, sql based store may replace +/- Infinity with max / min float values.

  • step (int, optional) – A single integer step at which to log the specified Metrics. If unspecified, each metric is logged at step zero.

log_param(key: str, value: any) None[source]

Log a parameter (e.g. model hyperparameter) under the current run.

Parameters:
  • key (str) – Parameter name. This string may only contain alphanumerics, underscores (_), dashes (-), periods (.), spaces ( ), and slashes (/). All backend stores support keys up to length 250, but some may support larger keys.

  • value (any) – Parameter value, of type string, but will be string-ified if not. All backend stores support values up to length 500, but some may support larger values.

log_params(values: dict) None[source]

Log a batch of params for the current run.

Parameters:

values (dict) – Dictionary of param_name: String -> value: (String, but will be string-ified if not)

log_text(text: str, artifact_file_path: str) None[source]

Log text as an artifact under the current run.

Parameters:
  • text (str) – String of text to log.

  • artifact_file_path (str) – The run-relative artifact file path in posixpath format to which the text is saved (e.g. “dir/file.txt”).

set_tag(key: str, tag: any) None[source]

Set a tag under the current run.

Parameters:
  • key (str) – Name of the tag.

  • tag (any) – Tag value (string, but will be string-ified if not). All backend stores will support values up to length 5000, but some may support larger values.

set_tags(tags: dict) None[source]

Log a batch of tags for the current run.

Parameters:

tags (dict) – Dictionary of tag_name: String -> value: (String, but will be string-ified if not)

class SummaryWriter[source]

Bases: object

SummaryWriter mimics the usage of Tensorboard’s SummaryWriter.

Users can replace the import of Tensorboard’s SummaryWriter with FLARE’s SummaryWriter. They would then use SummaryWriter the same as before. SummaryWriter will send log records to the FLARE system.

add_scalar(tag: str, scalar: float, global_step: int | None = None, **kwargs)[source]

Sends a scalar.

Parameters:
  • tag (str) – Data identifier.

  • scalar (float) – Value to send.

  • global_step (optional, int) – Global step value.

  • **kwargs – Additional arguments to pass to the receiver side.

add_scalars(tag: str, scalars: dict, global_step: int | None = None, **kwargs)[source]

Sends scalars.

Parameters:
  • tag (str) – The parent name for the tags.

  • scalars (dict) – Key-value pair storing the tag and corresponding values.

  • global_step (optional, int) – Global step value.

  • **kwargs – Additional arguments to pass to the receiver side.

class WandBWriter[source]

Bases: object

WandBWriter mimics the usage of weights and biases.

Users can replace the import of wandb with FLARE’s WandBWriter. They would then use WandBWriter the same as they would use wandb. WandBWriter will send log records to the FLARE system.

log(metrics: Dict[str, float], step: int | None = None)[source]

Log multiple metrics for the current run.

Parameters:
  • metrics (Dict[str, float]) – Dictionary of metric_name of type String to Float values.

  • step (int, optional) – A single integer step at which to log the specified Metrics.