class_docstr: Handle to an H2O server launched locally.
  
  Public interface::
  
      hs = H2OLocalServer.start(...)  # launch a new local H2O server
      hs.is_running()                 # check if the server is running
      hs.shutdown()                   # shut down the server
      hs.scheme                       # either "http" or "https"
      hs.ip                           # ip address of the server, typically "127.0.0.1"
      hs.port                         # port on which the server is listening
  
  Once started, the server will run until the script terminates, or until you call ``.shutdown()`` on it. Moreover,
  if the server terminates with an exception, then the server will not stop and will continue to run even after
  Python process exits. This runaway process may end up being in a bad shape (e.g. frozen), then the only way to
  terminate it is to end the Java process from the terminal.
  
  Alternatively, it is possible to start the server as a context manager, in which case it will be automatically
  shut down even if an exception occurs in Python (but not if the Python process is killed)::
  
      with H2OLocalServer.start() as hs:
          # do something with the server -- probably connect to it
class_docstr_tok: ["Handle","to","an","H2O","server","launched","locally",".","Public","interface",":",":","hs","=","H2OLocalServer.start","(","...",")","#","launch","a","new","local","H2O","server","hs.is_running","(",")","#","check","if","the","server","is","running","hs.shutdown","(",")","#","shut","down","the","server","hs.scheme","#","either","``","http","''","or","``","https","''","hs.ip","#","ip","address","of","the","server",",","typically","``","127.0.0.1","''","hs.port","#","port","on","which","the","server","is","listening","Once","started",",","the","server","will","run","until","the","script","terminates",",","or","until","you","call","``",".shutdown","(",")","``","on","it",".","Moreover",",","if","the","server","terminates","with","an","exception",",","then","the","server","will","not","stop","and","will","continue","to","run","even","after","Python","process","exits",".","This","runaway","process","may","end","up","being","in","a","bad","shape","(","e.g",".","frozen",")",",","then","the","only","way","to","terminate","it","is","to","end","the","Java","process","from","the","terminal",".","Alternatively",",","it","is","possible","to","start","the","server","as","a","context","manager",",","in","which","case","it","will","be","automatically","shut","down","even","if","an","exception","occurs","in","Python","(","but","not","if","the","Python","process","is","killed",")",":",":","with","H2OLocalServer.start","(",")","as","hs",":","#","do","something","with","the","server","--","probably","connect","to","it"]
docstr: Start new H2O server on the local machine.
  
  :param jar_path: Path to the h2o.jar executable. If not given, then we will search for h2o.jar in the
      locations returned by ``._jar_paths()``.
  :param nthreads: Number of threads in the thread pool. This should be related to the number of CPUs used.
      -1 means use all CPUs on the host. A positive integer specifies the number of CPUs directly.
  :param enable_assertions: If True, pass ``-ea`` option to the JVM.
  :param max_mem_size: Maximum heap size (jvm option Xmx), in bytes.
  :param min_mem_size: Minimum heap size (jvm option Xms), in bytes.
  :param log_dir: Directory for H2O logs to be stored if a new instance is started. Default directory is determined
      by H2O internally.
  :param log_level: The logger level for H2O if a new instance is started.
  :param max_log_file_size: Maximum size of INFO and DEBUG log files. The file is rolled over after a specified 
      size has been reached. (The default is 3MB. Minimum is 1MB and maximum is 99999MB)
  :param ice_root: A directory where H2O stores its temporary files. Default location is determined by
      ``tempfile.mkdtemp()``.
  :param port: Port where to start the new server. This could be either an integer, or a string of the form
      "DDDDD+", indicating that the server should start looking for an open port starting from DDDDD and up.
  :param name: name of the h2o cluster to be started.
  :param extra_classpath: List of paths to libraries that should be included on the Java classpath.
  :param verbose: If True, then connection info will be printed to the stdout.
  :param jvm_custom_args: Custom, user-defined arguments for the JVM H2O is instantiated in.
  :param bind_to_localhost: A flag indicating whether access to the H2O instance should be restricted to the local
      machine (default) or if it can be reached from other computers on the network.
      Only applicable when H2O is started from the Python client.
  
  :returns: a new H2OLocalServer instance.
docstr_tok: ["Start","new","H2O","server","on","the","local","machine",".",":","param","jar_path",":","Path","to","the","h2o.jar","executable",".","If","not","given",",","then","we","will","search","for","h2o.jar","in","the","locations","returned","by","``","._jar_paths","(",")","``",".",":","param","nthreads",":","Number","of","threads","in","the","thread","pool",".","This","should","be","related","to","the","number","of","CPUs","used",".","-1","means","use","all","CPUs","on","the","host",".","A","positive","integer","specifies","the","number","of","CPUs","directly",".",":","param","enable_assertions",":","If","True",",","pass","``","-ea","``","option","to","the","JVM",".",":","param","max_mem_size",":","Maximum","heap","size","(","jvm","option","Xmx",")",",","in","bytes",".",":","param","min_mem_size",":","Minimum","heap","size","(","jvm","option","Xms",")",",","in","bytes",".",":","param","log_dir",":","Directory","for","H2O","logs","to","be","stored","if","a","new","instance","is","started",".","Default","directory","is","determined","by","H2O","internally",".",":","param","log_level",":","The","logger","level","for","H2O","if","a","new","instance","is","started",".",":","param","max_log_file_size",":","Maximum","size","of","INFO","and","DEBUG","log","files",".","The","file","is","rolled","over","after","a","specified","size","has","been","reached",".","(","The","default","is","3MB",".","Minimum","is","1MB","and","maximum","is","99999MB",")",":","param","ice_root",":","A","directory","where","H2O","stores","its","temporary","files",".","Default","location","is","determined","by","``","tempfile.mkdtemp","(",")","``",".",":","param","port",":","Port","where","to","start","the","new","server",".","This","could","be","either","an","integer",",","or","a","string","of","the","form","``","DDDDD+","''",",","indicating","that","the","server","should","start","looking","for","an","open","port","starting","from","DDDDD","and","up",".",":","param","name",":","name","of","the","h2o","cluster","to","be","started",".",":","param","extra_classpath",":","List","of","paths","to","libraries","that","should","be","included","on","the","Java","classpath",".",":","param","verbose",":","If","True",",","then","connection","info","will","be","printed","to","the","stdout",".",":","param","jvm_custom_args",":","Custom",",","user-defined","arguments","for","the","JVM","H2O","is","instantiated","in",".",":","param","bind_to_localhost",":","A","flag","indicating","whether","access","to","the","H2O","instance","should","be","restricted","to","the","local","machine","(","default",")","or","if","it","can","be","reached","from","other","computers","on","the","network",".","Only","applicable","when","H2O","is","started","from","the","Python","client",".",":","returns",":","a","new","H2OLocalServer","instance","."]
code: def start(
      jar_path=None,
      nthreads=-1,
      enable_assertions=True,
      max_mem_size=None,
      min_mem_size=None,
      ice_root=None,
      log_dir=None,
      log_level=None,
      max_log_file_size=None,
      port="54321+",
      name=None,
      extra_classpath=None,
      verbose=True,
      jvm_custom_args=None,
      bind_to_localhost=True,
  ):
      """
      Start new H2O server on the local machine.
  
      :param jar_path: Path to the h2o.jar executable. If not given, then we will search for h2o.jar in the
          locations returned by ``._jar_paths()``.
      :param nthreads: Number of threads in the thread pool. This should be related to the number of CPUs used.
          -1 means use all CPUs on the host. A positive integer specifies the number of CPUs directly.
      :param enable_assertions: If True, pass ``-ea`` option to the JVM.
      :param max_mem_size: Maximum heap size (jvm option Xmx), in bytes.
      :param min_mem_size: Minimum heap size (jvm option Xms), in bytes.
      :param log_dir: Directory for H2O logs to be stored if a new instance is started. Default directory is determined
          by H2O internally.
      :param log_level: The logger level for H2O if a new instance is started.
      :param max_log_file_size: Maximum size of INFO and DEBUG log files. The file is rolled over after a specified
          size has been reached. (The default is 3MB. Minimum is 1MB and maximum is 99999MB)
      :param ice_root: A directory where H2O stores its temporary files. Default location is determined by
          ``tempfile.mkdtemp()``.
      :param port: Port where to start the new server. This could be either an integer, or a string of the form
          "DDDDD+", indicating that the server should start looking for an open port starting from DDDDD and up.
      :param name: name of the h2o cluster to be started.
      :param extra_classpath: List of paths to libraries that should be included on the Java classpath.
      :param verbose: If True, then connection info will be printed to the stdout.
      :param jvm_custom_args: Custom, user-defined arguments for the JVM H2O is instantiated in.
      :param bind_to_localhost: A flag indicating whether access to the H2O instance should be restricted to the local
          machine (default) or if it can be reached from other computers on the network.
          Only applicable when H2O is started from the Python client.
  
      :returns: a new H2OLocalServer instance.
      """
      assert_is_type(jar_path, None, str)
      assert_is_type(port, None, int, str)
      assert_is_type(name, None, str)
      assert_is_type(nthreads, -1, BoundInt(1, 4096))
      assert_is_type(enable_assertions, bool)
      assert_is_type(min_mem_size, None, int)
      assert_is_type(max_mem_size, None, BoundInt(1 << 25))
      assert_is_type(log_dir, str, None)
      assert_is_type(log_level, str, None)
      assert_satisfies(
          log_level,
          log_level
          in [None, "TRACE", "DEBUG", "INFO", "WARN", "ERRR", "FATA"],
      )
      assert_is_type(max_log_file_size, str, None)
      assert_is_type(ice_root, None, I(str, os.path.isdir))
      assert_is_type(extra_classpath, None, [str])
      assert_is_type(jvm_custom_args, list, None)
      assert_is_type(bind_to_localhost, bool)
      if jar_path:
          assert_satisfies(jar_path, jar_path.endswith("h2o.jar"))
  
      if (
          min_mem_size is not None
          and max_mem_size is not None
          and min_mem_size > max_mem_size
      ):
          raise H2OValueError(
              "`min_mem_size`=%d is larger than the `max_mem_size`=%d"
              % (min_mem_size, max_mem_size)
          )
      if port is None:
          port = "54321+"
      baseport = None
      # TODO: get rid of this port gimmick and have 2 separate parameters.
      if is_type(port, str):
          if port.isdigit():
              port = int(port)
          else:
              if not (port[-1] == "+" and port[:-1].isdigit()):
                  raise H2OValueError(
                      "`port` should be of the form 'DDDD+', where D is a digit. Got: %s"
                      % port
                  )
              baseport = int(port[:-1])
              port = 0
  
      hs = H2OLocalServer()
      hs._verbose = bool(verbose)
      hs._jar_path = hs._find_jar(jar_path)
      hs._extra_classpath = extra_classpath
      hs._ice_root = ice_root
      hs._name = name
      if not ice_root:
          hs._ice_root = tempfile.mkdtemp()
          hs._tempdir = hs._ice_root
  
      if verbose:
          print("Attempting to start a local H2O server...")
      hs._launch_server(
          port=port,
          baseport=baseport,
          nthreads=int(nthreads),
          ea=enable_assertions,
          mmax=max_mem_size,
          mmin=min_mem_size,
          jvm_custom_args=jvm_custom_args,
          bind_to_localhost=bind_to_localhost,
          log_dir=log_dir,
          log_level=log_level,
          max_log_file_size=max_log_file_size,
      )
      if verbose:
          print(
              "  Server is running at %s://%s:%d"
              % (hs.scheme, hs.ip, hs.port)
          )
      atexit.register(lambda: hs.shutdown())
      return hs
  
imports: from h2o.utils.compatibility import *
  import atexit
  import os
  import subprocess
  import sys
  import tempfile
  import time
  import re
  from random import choice
  from sysconfig import get_config_var
  from warnings import warn
  from h2o.exceptions import H2OServerError, H2OStartupError, H2OValueError
  from h2o.utils.typechecks import assert_is_type, assert_satisfies, BoundInt, I, is_type
label_desc: Use image node_id 1 for calling the H2OLocalServer obj's underlying member method code with example usage: obj.start(jar_path, nthreads, enable_assertions, max_mem_size, min_mem_size, ice_root, log_dir, log_level, max_log_file_size, port, name, extra_classpath, verbose, jvm_custom_args, bind_to_localhost) and returns: hs