code: def connect(
      name: str,
      service: DataprocConnectService,
      project: Optional[str],
      port: str,
      zone: Optional[str],
      dry_run: bool,
      pass_through_args: List[str],
  ):
      service = service.shortcut()
  
      # Dataproc port mapping
      dataproc_port_and_path = {
          DataprocConnectService.SPARK_UI: "18080/?showIncomplete=true",
          DataprocConnectService.SPARK_HISTORY: "18080",
          DataprocConnectService.NOTEBOOK: "8123",
      }
      connect_port_and_path = dataproc_port_and_path[service]
  
      zone = zone if zone else gcloud.get_config("compute/zone")
      if not zone:
          raise RuntimeError(
              "Could not determine compute zone. Use --zone argument to hailctl, or use `gcloud config set compute/zone <my-zone>` to set a default."
          )
  
      account = gcloud.get_config("account")
      if account:
          account = account[0 : account.find("@")]
          ssh_login = "{}@{}-m".format(account, name)
      else:
          ssh_login = "{}-m".format(name)
  
      cmd = [
          "compute",
          "ssh",
          ssh_login,
          "--zone={}".format(zone),
          "--ssh-flag=-D {}".format(port),
          "--ssh-flag=-N",
          "--ssh-flag=-f",
          "--ssh-flag=-n",
          *pass_through_args,
      ]
  
      if project:
          cmd.append(f"--project={project}")
  
      print("gcloud command:")
      print(
          " ".join(cmd[:4])
          + " \\\n    "
          + " \\\n    ".join([f"'{x}'" for x in cmd[4:]])
      )
  
      if not dry_run:
          print("Connecting to cluster '{}'...".format(name))
  
          # open SSH tunnel to master node
          gcloud.run(cmd)
  
          chrome = os.environ.get("HAILCTL_CHROME") or get_chrome_path()
          data_dir = (
              os.environ.get("HAILCTL_CHROME_DATA_DIR")
              or get_datadir_path()
          )
  
          # open Chrome with SOCKS proxy configuration
          with subprocess.Popen(
              [  # pylint: disable=consider-using-with
                  chrome,
                  f"http://{name}-m:{connect_port_and_path}",
                  f"--proxy-server=socks5://localhost:{port}",
                  f"--user-data-dir={data_dir}",
              ],
              stdout=subprocess.DEVNULL,
              stderr=subprocess.DEVNULL,
          ):
              pass
  
file_path: hail/hail/python/hailtop/hailctl/dataproc/connect.py
imports: from enum import Enum
  import os
  import platform
  import shutil
  import subprocess
  import tempfile
  from typing import Optional, List
  from .None import gcloud
label_desc: Use image node_id 3 for calling a global function with example usage: connect(name, service, project, port, zone, dry_run, pass_through_args) without return types