nvflare.app_opt.tracking.mlflow.mlflow_writer module¶
- class MLflowWriter(event_type: str = 'analytix_log_stats')[source]¶
Bases:
LogWriter
MLflowWriter mimics the usage of mlflow.
Users can replace the import of mlflow with MLflowWriter. They would then use MLflowWriter the same as they would use mlflow. MLflowWriter will send log records to the receiver.
- Parameters:
event_type (str, optional) – _description_. Defaults to ANALYTIC_EVENT_TYPE.
- get_default_metric_data_type() AnalyticsDataType [source]¶
- get_writer_name() LogWriterName [source]¶
Returns “MLFLOW”.
- 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”).