class_docstr: Abstract class for implementing the strategy for launching the master instance of the cluster.
class_docstr_tok: ["Abstract","class","for","implementing","the","strategy","for","launching","the","master","instance","of","the","cluster","."]
docstr: Launch a master instance.
  
  Note:
      If you create a custom subclass of MasterLauncher which will not start the master instance on localhost
      then you should pass the debug flag on to `execute_task()` of the `RuntimeGroup` or `Runtime` so that you
      can benefit from the debug feature of `RuntimeTask.execute()`.
  
  Args:
      ports: Port where the master should be started. If a list is given then the first port that is free in the
            `RuntimeGroup` will be used. The actual chosen port can requested via the property `port`.
      timeout: Timeout (s) after which an MasterStartError is raised if master instance not started yet.
      debug: If `True`, stdout/stderr from the runtime will be printed to stdout of localhost. If, `False` then
             the stdout/stderr will be added to python logger with level debug after each task step. Defaults to
             `False`.
  
  Returns:
      List[int]: In case a port list was given the updated port list will be returned. Otherwise an empty list.
  
  Raises:
      PortInUseError: If a single port is given and it is not free in the `RuntimeGroup`.
      NoPortsLeftError: If a port list was given and none of the ports is actually free in the `RuntimeGroup`.
      MasterStartError: If master was not started after the specified `timeout`.
docstr_tok: ["Launch","a","master","instance",".","Note",":","If","you","create","a","custom","subclass","of","MasterLauncher","which","will","not","start","the","master","instance","on","localhost","then","you","should","pass","the","debug","flag","on","to","`","execute_task","(",")","`","of","the","`","RuntimeGroup","`","or","`","Runtime","`","so","that","you","can","benefit","from","the","debug","feature","of","`","RuntimeTask.execute","(",")","`",".","Args",":","ports",":","Port","where","the","master","should","be","started",".","If","a","list","is","given","then","the","first","port","that","is","free","in","the","`","RuntimeGroup","`","will","be","used",".","The","actual","chosen","port","can","requested","via","the","property","`","port","`",".","timeout",":","Timeout","(","s",")","after","which","an","MasterStartError","is","raised","if","master","instance","not","started","yet",".","debug",":","If","`","True","`",",","stdout\/stderr","from","the","runtime","will","be","printed","to","stdout","of","localhost",".","If",",","`","False","`","then","the","stdout\/stderr","will","be","added","to","python","logger","with","level","debug","after","each","task","step",".","Defaults","to","`","False","`",".","Returns",":","List","[","int","]",":","In","case","a","port","list","was","given","the","updated","port","list","will","be","returned",".","Otherwise","an","empty","list",".","Raises",":","PortInUseError",":","If","a","single","port","is","given","and","it","is","not","free","in","the","`","RuntimeGroup","`",".","NoPortsLeftError",":","If","a","port","list","was","given","and","none","of","the","ports","is","actually","free","in","the","`","RuntimeGroup","`",".","MasterStartError",":","If","master","was","not","started","after","the","specified","`","timeout","`","."]
code: def start(
      self,
      ports: Union[List[int], int],
      timeout: int = 3,
      debug: bool = False,
  ) -> List[int]:
      """Launch a master instance.
  
      Note:
          If you create a custom subclass of MasterLauncher which will not start the master instance on localhost
          then you should pass the debug flag on to `execute_task()` of the `RuntimeGroup` or `Runtime` so that you
          can benefit from the debug feature of `RuntimeTask.execute()`.
  
      Args:
          ports: Port where the master should be started. If a list is given then the first port that is free in the
                `RuntimeGroup` will be used. The actual chosen port can requested via the property `port`.
          timeout: Timeout (s) after which an MasterStartError is raised if master instance not started yet.
          debug: If `True`, stdout/stderr from the runtime will be printed to stdout of localhost. If, `False` then
                 the stdout/stderr will be added to python logger with level debug after each task step. Defaults to
                 `False`.
  
      Returns:
          List[int]: In case a port list was given the updated port list will be returned. Otherwise an empty list.
  
      Raises:
          PortInUseError: If a single port is given and it is not free in the `RuntimeGroup`.
          NoPortsLeftError: If a port list was given and none of the ports is actually free in the `RuntimeGroup`.
          MasterStartError: If master was not started after the specified `timeout`.
      """
  
      # The actual values for the following instance attributes need to be set within the concrete implementations:
      # - self._port
      # - self._process (In case the master is started in a process managed by the MasterLauncher instance )
  
      raise NotImplementedError
  
imports: import atexit
  import logging
  from subprocess import Popen
  from typing import Dict, List, Optional, Union
  from lazycluster.exceptions import LazyclusterError
  from lazycluster.runtime_mgmt import RuntimeGroup
label_desc: Use image node_id 4 for calling the MasterLauncher obj's underlying member method code with example usage: obj.start(ports, timeout, debug) without return types