class_docstr: Class for collecting resource usage info from this or child process.
class_docstr_tok: ["Class","for","collecting","resource","usage","info","from","this","or","child","process","."]
docstr: Collects and return runtime metrics as a ResourceMetrics proto.
  
  This method can be called multiple times, but wall clock time is always
  reckoned from the time of the last start() call.
  
  Returns:
    A learning.genomics.deepvariant.ResourceMetrics proto message.
  
  Raises:
    RuntimeError: if start() was not called previously.
docstr_tok: ["Collects","and","return","runtime","metrics","as","a","ResourceMetrics","proto",".","This","method","can","be","called","multiple","times",",","but","wall","clock","time","is","always","reckoned","from","the","time","of","the","last","start","(",")","call",".","Returns",":","A","learning.genomics.deepvariant.ResourceMetrics","proto","message",".","Raises",":","RuntimeError",":","if","start","(",")","was","not","called","previously","."]
code: def metrics(self):
      """Collects and return runtime metrics as a ResourceMetrics proto.
  
      This method can be called multiple times, but wall clock time is always
      reckoned from the time of the last start() call.
  
      Returns:
        A learning.genomics.deepvariant.ResourceMetrics proto message.
  
      Raises:
        RuntimeError: if start() was not called previously.
      """
      if self.wall_start is None:
          raise RuntimeError(
              "start() must be called prior to metrics()"
          )
  
      self.metrics_pb.wall_time_seconds = time.time() - self.wall_start
  
      # Consider using psutil.cpu_times() instead to get more detailed information
      # about the usage in self and all children.
      try:
          rusage = resource.getrusage(resource.RUSAGE_SELF)
          self.metrics_pb.cpu_user_time_seconds = rusage.ru_utime
          self.metrics_pb.cpu_system_time_seconds = rusage.ru_stime
          self.metrics_pb.memory_peak_rss_mb = int(
              rusage.ru_maxrss / 1024
          )
      except resource.error:
          # The OS call to get rusage failed, so just don't set the field values,
          # leaving them as the default values of 0.
          pass
  
      # Create a psutil.Process pointed at the current process.
      process = psutil.Process()
      io_counters = process.io_counters()
      self.metrics_pb.read_bytes = io_counters.read_bytes
      self.metrics_pb.write_bytes = io_counters.write_bytes
  
      return self.metrics_pb
  
file_path: deepvariant/deepvariant/resources.py
imports: import platform
  import resource
  import time
  import psutil
  from deepvariant.protos import resources_pb2
label_desc: Use image node_id 6 for calling the ResourceMonitor obj's underlying member method code with example usage: obj.metrics() and returns: self