class_docstr: Class for monitoring system stats.
  
  This class is used for pulling system metrics and logging them to MLflow. Calling `start()` will
  spawn a thread that logs system metrics periodically. Calling `finish()` will stop the thread.
  Logging is done on a different frequency from pulling metrics, so that the metrics are
  aggregated over the period. Users can change the logging frequency by setting
  `MLFLOW_SYSTEM_METRICS_SAMPLING_INTERVAL` and `MLFLOW_SYSTEM_METRICS_SAMPLES_BEFORE_LOGGING`
  environment variables, e.g., run `export MLFLOW_SYSTEM_METRICS_SAMPLING_INTERVAL=10` in terminal
  will set the sampling interval to 10 seconds.
  
  System metrics are logged with a prefix "system/", e.g., "system/cpu_utilization_percentage".
  
  Args:
      run_id: string, the MLflow run ID.
      sampling_interval: float, default to 10. The interval (in seconds) at which to pull system
          metrics. Will be overridden by `MLFLOW_SYSTEM_METRICS_SAMPLING_INTERVAL` environment
          variable.
      samples_before_logging: int, default to 1. The number of samples to aggregate before
          logging. Will be overridden by `MLFLOW_SYSTEM_METRICS_SAMPLES_BEFORE_LOGGING`
          evnironment variable.
      resume_logging: bool, default to False. If True, we will resume the system metrics logging
          from the `run_id`, and the first step to log will be the last step of `run_id` + 1, if
          False, system metrics logging will start from step 0.
class_docstr_tok: ["Class","for","monitoring","system","stats",".","This","class","is","used","for","pulling","system","metrics","and","logging","them","to","MLflow",".","Calling","`","start","(",")","`","will","spawn","a","thread","that","logs","system","metrics","periodically",".","Calling","`","finish","(",")","`","will","stop","the","thread",".","Logging","is","done","on","a","different","frequency","from","pulling","metrics",",","so","that","the","metrics","are","aggregated","over","the","period",".","Users","can","change","the","logging","frequency","by","setting","`","MLFLOW_SYSTEM_METRICS_SAMPLING_INTERVAL","`","and","`","MLFLOW_SYSTEM_METRICS_SAMPLES_BEFORE_LOGGING","`","environment","variables",",","e.g.",",","run","`","export","MLFLOW_SYSTEM_METRICS_SAMPLING_INTERVAL=10","`","in","terminal","will","set","the","sampling","interval","to","10","seconds",".","System","metrics","are","logged","with","a","prefix","``","system\/","''",",","e.g.",",","``","system\/cpu_utilization_percentage","''",".","Args",":","run_id",":","string",",","the","MLflow","run","ID",".","sampling_interval",":","float",",","default","to","10",".","The","interval","(","in","seconds",")","at","which","to","pull","system","metrics",".","Will","be","overridden","by","`","MLFLOW_SYSTEM_METRICS_SAMPLING_INTERVAL","`","environment","variable",".","samples_before_logging",":","int",",","default","to","1",".","The","number","of","samples","to","aggregate","before","logging",".","Will","be","overridden","by","`","MLFLOW_SYSTEM_METRICS_SAMPLES_BEFORE_LOGGING","`","evnironment","variable",".","resume_logging",":","bool",",","default","to","False",".","If","True",",","we","will","resume","the","system","metrics","logging","from","the","`","run_id","`",",","and","the","first","step","to","log","will","be","the","last","step","of","`","run_id","`","+","1",",","if","False",",","system","metrics","logging","will","start","from","step","0","."]
docstr: Log collected metrics to MLflow.
docstr_tok: ["Log","collected","metrics","to","MLflow","."]
code: def publish_metrics(self, metrics):
      """Log collected metrics to MLflow."""
      # Add prefix "system/" to the metrics name for grouping.
      metrics = {
          self._metrics_prefix + k: v for k, v in metrics.items()
      }
  
      self.mlflow_logger.record_metrics(metrics, self._logging_step)
      self._logging_step += 1
      for monitor in self.monitors:
          monitor.clear_metrics()
  
file_path: mlflow/mlflow/system_metrics/system_metrics_monitor.py
imports: import logging
  import threading
  from mlflow.environment_variables import MLFLOW_SYSTEM_METRICS_SAMPLES_BEFORE_LOGGING, MLFLOW_SYSTEM_METRICS_SAMPLING_INTERVAL
  from mlflow.exceptions import MlflowException
  from mlflow.system_metrics.metrics.cpu_monitor import CPUMonitor
  from mlflow.system_metrics.metrics.disk_monitor import DiskMonitor
  from mlflow.system_metrics.metrics.gpu_monitor import GPUMonitor
  from mlflow.system_metrics.metrics.network_monitor import NetworkMonitor
label_desc: Use image node_id 7 for calling the SystemMetricsMonitor obj's underlying member method code with example usage: obj.publish_metrics(metrics) without return types