class_docstr: Convenient class for launching a Dask cluster in a `RuntimeGroup`.
  
  DaskCluster inherits from MasterWorkerCluster. See its documentation to get a list of the inherited methods
  and attributes.
  
  The number of DASK workers defaults to the number of `Runtimes` in the used `RuntimeGroup`. This number can be
  adjusted so that more or less workers than available `Runtimes` can be used. Per default the desired number of
  workers is started in a round robin way as implemented in `RoundRobinLauncher`. Consequently, this leads to an
  equal distribution of DASK workers in the `RuntimeGroup`. You can provide a custom implementation inheriting from
  the `WorkerLauncher` class in order to execute a different strategy how workers should be started. The
  DASK master (i.e. scheduler) will always be started on localhost as implemented in `LocalMasterLauncher`. This
  behavior can also be changed by providing a custom implementation inheriting from the `MasterLauncher`.
class_docstr_tok: ["Convenient","class","for","launching","a","Dask","cluster","in","a","`","RuntimeGroup","`",".","DaskCluster","inherits","from","MasterWorkerCluster",".","See","its","documentation","to","get","a","list","of","the","inherited","methods","and","attributes",".","The","number","of","DASK","workers","defaults","to","the","number","of","`","Runtimes","`","in","the","used","`","RuntimeGroup","`",".","This","number","can","be","adjusted","so","that","more","or","less","workers","than","available","`","Runtimes","`","can","be","used",".","Per","default","the","desired","number","of","workers","is","started","in","a","round","robin","way","as","implemented","in","`","RoundRobinLauncher","`",".","Consequently",",","this","leads","to","an","equal","distribution","of","DASK","workers","in","the","`","RuntimeGroup","`",".","You","can","provide","a","custom","implementation","inheriting","from","the","`","WorkerLauncher","`","class","in","order","to","execute","a","different","strategy","how","workers","should","be","started",".","The","DASK","master","(","i.e",".","scheduler",")","will","always","be","started","on","localhost","as","implemented","in","`","LocalMasterLauncher","`",".","This","behavior","can","also","be","changed","by","providing","a","custom","implementation","inheriting","from","the","`","MasterLauncher","`","."]
docstr: Initialization method.
  
  Args:
      runtime_group: The `RuntimeGroup` contains all `Runtimes` which can be used for starting the DASK entities.
      ports: The list of ports which will be used to instantiate a cluster. Defaults to
                                  `list(range(self.DEFAULT_PORT_RANGE_START, self.DEFAULT_PORT_RANGE_END))`.
      master_launcher: Optionally, an instance implementing the `MasterLauncher` interface can be given, which
                       implements the strategy for launching the master instances in the cluster. If None, then
                       `LocalMasterLauncher` is used.
      worker_launcher: Optionally, an instance implementing the `WorkerLauncher` interface can be given, which
                       implements the strategy for launching the worker instances. If None, then
                       `RoundRobinLauncher` is used.
docstr_tok: ["Initialization","method",".","Args",":","runtime_group",":","The","`","RuntimeGroup","`","contains","all","`","Runtimes","`","which","can","be","used","for","starting","the","DASK","entities",".","ports",":","The","list","of","ports","which","will","be","used","to","instantiate","a","cluster",".","Defaults","to","`","list","(","range","(","self.DEFAULT_PORT_RANGE_START",",","self.DEFAULT_PORT_RANGE_END",")",")","`",".","master_launcher",":","Optionally",",","an","instance","implementing","the","`","MasterLauncher","`","interface","can","be","given",",","which","implements","the","strategy","for","launching","the","master","instances","in","the","cluster",".","If","None",",","then","`","LocalMasterLauncher","`","is","used",".","worker_launcher",":","Optionally",",","an","instance","implementing","the","`","WorkerLauncher","`","interface","can","be","given",",","which","implements","the","strategy","for","launching","the","worker","instances",".","If","None",",","then","`","RoundRobinLauncher","`","is","used","."]
code: def __init__(
      self,
      runtime_group: RuntimeGroup,
      ports: Optional[List[int]] = None,
      master_launcher: Optional[MasterLauncher] = None,
      worker_launcher: Optional[WorkerLauncher] = None,
  ):
      """Initialization method.
  
      Args:
          runtime_group: The `RuntimeGroup` contains all `Runtimes` which can be used for starting the DASK entities.
          ports: The list of ports which will be used to instantiate a cluster. Defaults to
                                      `list(range(self.DEFAULT_PORT_RANGE_START, self.DEFAULT_PORT_RANGE_END))`.
          master_launcher: Optionally, an instance implementing the `MasterLauncher` interface can be given, which
                           implements the strategy for launching the master instances in the cluster. If None, then
                           `LocalMasterLauncher` is used.
          worker_launcher: Optionally, an instance implementing the `WorkerLauncher` interface can be given, which
                           implements the strategy for launching the worker instances. If None, then
                           `RoundRobinLauncher` is used.
      """
      super().__init__(runtime_group, ports)
  
      self._master_launcher = (
          master_launcher
          if master_launcher
          else LocalMasterLauncher(runtime_group)
      )
      self._worker_launcher = (
          worker_launcher
          if worker_launcher
          else RoundRobinLauncher(runtime_group)
      )
  
      self.log.debug("DaskCluster initialized.")
  
imports: import time
  from subprocess import Popen
  from typing import List, Optional, Union
  from distributed import Client
  from lazycluster import Runtime, RuntimeGroup, RuntimeTask, _utils
  from lazycluster.cluster import MasterLauncher, MasterWorkerCluster, WorkerLauncher
  from lazycluster.cluster.exceptions import MasterStartError
  from lazycluster.exceptions import NoPortsLeftError, PortInUseError
label_desc: Use image node_id 1 to create a new DaskCluster object from inherited base classes: MasterWorkerCluster with example: obj = DaskCluster(runtime_group, ports, master_launcher, worker_launcher)