class_docstr: The `RuntimeManager` can be used for a simplified resource management.
  
  It aims to automatically detect valid `Runtimes` based on the ssh configuration.
  It can be used to create a `RuntimeGroup` based on the automatically detected
  instances and possibly based on further filters such as GPU availability.
class_docstr_tok: ["The","`","RuntimeManager","`","can","be","used","for","a","simplified","resource","management",".","It","aims","to","automatically","detect","valid","`","Runtimes","`","based","on","the","ssh","configuration",".","It","can","be","used","to","create","a","`","RuntimeGroup","`","based","on","the","automatically","detected","instances","and","possibly","based","on","further","filters","such","as","GPU","availability","."]
docstr: Initialization method.
  
  Raises:
      NoRuntimeDetectedError: If no `Runtime` could be automatically detected.
docstr_tok: ["Initialization","method",".","Raises",":","NoRuntimeDetectedError",":","If","no","`","Runtime","`","could","be","automatically","detected","."]
code: def __init__(self) -> None:
      """Initialization method.
  
      Raises:
          NoRuntimeDetectedError: If no `Runtime` could be automatically detected.
      """
      # Create the Logger
      self.log = logging.getLogger(__name__)
  
      runtimes = {}
      self.inactive_hosts = []
  
      # Iterate over ssh configuration entries and look for valid RemoteRuntimes
      ssh_util = Storm()
      self.log.debug(
          "RuntimeManager starts looking for Runtimes based on ssh configuration."
      )
  
      for ssh_entry in ssh_util.list_entries(only_servers=True):
          if ssh_entry["host"] in runtimes:
              continue
          if (
              ssh_entry["host"] == "localhost"
              and "127.0.0.1" in runtimes
          ) or (
              ssh_entry["host"] == "127.0.0.1"
              and "localhost" in runtimes
          ):
              continue
          try:
              self.log.debug(
                  f'RuntimeManager tries to instantiate host {ssh_entry["host"]} as Runtime.'
              )
              runtime = Runtime(ssh_entry["host"])
          except InvalidRuntimeError:
              self.inactive_hosts.append(ssh_entry["host"])
              self.log.debug(
                  f'RuntimeManager detected host config for {ssh_entry["host"]}, that could NOT be '
                  f"instantiated  as a valid Runtime."
              )
              continue
          runtimes.update({runtime.host: runtime})
          self.log.info(
              runtime.host
              + " detected as valid Runtime by the RuntimeManager."
          )
  
      try:
          self._group = RuntimeGroup(list(runtimes.values()))
          self.log.info(
              f"RuntimeManager detected {len(runtimes)} valid Runtime(s)."
          )
      except ValueError as err:
          raise NoRuntimesDetectedError(err)
  
      self.log.debug("RuntimeManager initialized.")
  
imports: import atexit
  import logging
  import warnings
  from copy import deepcopy
  from multiprocessing import Pool, Process
  from typing import Dict, Generator, List, Optional, Union
  from storm import Storm
  from lazycluster import _utils
  from lazycluster.exceptions import InvalidRuntimeError, NoPortsLeftError, NoRuntimesDetectedError, PortInUseError
  from lazycluster.runtimes import Runtime, RuntimeTask
label_desc: Use image node_id 1 to create a new RuntimeManager object from inherited base classes: object with example: obj = RuntimeManager()