class_docstr: A local client for submitting and interacting with jobs on a remote cluster.
  
  Submits requests over HTTP to the job server on the cluster using the REST API.
  
  
  Args:
      address: Either (1) the address of the Ray cluster, or (2) the HTTP address
          of the dashboard server on the head node, e.g. "http://<head-node-ip>:8265".
          In case (1) it must be specified as an address that can be passed to
          ray.init(), e.g. a Ray Client address (ray://<head_node_host>:10001),
          or "auto", or "localhost:<port>". If unspecified, will try to connect to
          a running local Ray cluster. This argument is always overridden by the
          RAY_ADDRESS environment variable.
      create_cluster_if_needed: Indicates whether the cluster at the specified
          address needs to already be running. Ray doesn't start a cluster
          before interacting with jobs, but third-party job managers may do so.
      cookies: Cookies to use when sending requests to the HTTP job server.
      metadata: Arbitrary metadata to store along with all jobs.  New metadata
          specified per job will be merged with the global metadata provided here
          via a simple dict update.
      headers: Headers to use when sending requests to the HTTP job server, used
          for cases like authentication to a remote cluster.
      verify: Boolean indication to verify the server's TLS certificate or a path to
          a file or directory of trusted certificates. Default: True.
class_docstr_tok: ["A","local","client","for","submitting","and","interacting","with","jobs","on","a","remote","cluster",".","Submits","requests","over","HTTP","to","the","job","server","on","the","cluster","using","the","REST","API",".","Args",":","address",":","Either","(","1",")","the","address","of","the","Ray","cluster",",","or","(","2",")","the","HTTP","address","of","the","dashboard","server","on","the","head","node",",","e.g",".","``","http",":","\/\/","<","head-node-ip",">",":8265","''",".","In","case","(","1",")","it","must","be","specified","as","an","address","that","can","be","passed","to","ray.init","(",")",",","e.g",".","a","Ray","Client","address","(","ray",":","\/\/","<","head_node_host",">",":10001",")",",","or","``","auto","''",",","or","``","localhost",":","<","port",">","''",".","If","unspecified",",","will","try","to","connect","to","a","running","local","Ray","cluster",".","This","argument","is","always","overridden","by","the","RAY_ADDRESS","environment","variable",".","create_cluster_if_needed",":","Indicates","whether","the","cluster","at","the","specified","address","needs","to","already","be","running",".","Ray","does","n't","start","a","cluster","before","interacting","with","jobs",",","but","third-party","job","managers","may","do","so",".","cookies",":","Cookies","to","use","when","sending","requests","to","the","HTTP","job","server",".","metadata",":","Arbitrary","metadata","to","store","along","with","all","jobs",".","New","metadata","specified","per","job","will","be","merged","with","the","global","metadata","provided","here","via","a","simple","dict","update",".","headers",":","Headers","to","use","when","sending","requests","to","the","HTTP","job","server",",","used","for","cases","like","authentication","to","a","remote","cluster",".","verify",":","Boolean","indication","to","verify","the","server","'s","TLS","certificate","or","a","path","to","a","file","or","directory","of","trusted","certificates",".","Default",":","True","."]
code: def __init__(
      self,
      address: Optional[str] = None,
      create_cluster_if_needed: bool = False,
      cookies: Optional[Dict[str, Any]] = None,
      metadata: Optional[Dict[str, Any]] = None,
      headers: Optional[Dict[str, Any]] = None,
      verify: Optional[Union[str, bool]] = True,
  ):
      self._client_ray_version = ray.__version__
      """Initialize a JobSubmissionClient and check the connection to the cluster."""
      if requests is None:
          raise RuntimeError(
              "The Ray jobs CLI & SDK require the ray[default] "
              "installation: `pip install 'ray[default]'`"
          )
      # Check types of arguments
      if address is not None and not isinstance(address, str):
          raise TypeError(
              f"address must be a string, got {type(address)}"
          )
      if not isinstance(create_cluster_if_needed, bool):
          raise TypeError(
              f"create_cluster_if_needed must be a bool, got"
              f" {type(create_cluster_if_needed)}"
          )
      if cookies is not None and not isinstance(cookies, dict):
          raise TypeError(
              f"cookies must be a dict, got {type(cookies)}"
          )
      if metadata is not None and not isinstance(metadata, dict):
          raise TypeError(
              f"metadata must be a dict, got {type(metadata)}"
          )
      if headers is not None and not isinstance(headers, dict):
          raise TypeError(
              f"headers must be a dict, got {type(headers)}"
          )
      if not (isinstance(verify, str) or isinstance(verify, bool)):
          raise TypeError(
              f"verify must be a str or bool, got {type(verify)}"
          )
  
      api_server_url = get_address_for_submission_client(address)
  
      super().__init__(
          address=api_server_url,
          create_cluster_if_needed=create_cluster_if_needed,
          cookies=cookies,
          metadata=metadata,
          headers=headers,
          verify=verify,
      )
      self._check_connection_and_version(
          min_version="1.9",
          version_error_message="Jobs API is not supported on the Ray "
          "cluster. Please ensure the cluster is "
          "running Ray 1.9 or higher.",
      )
  
      # In ray>=2.0, the client sends the new kwarg `submission_id` to the server
      # upon every job submission, which causes servers with ray<2.0 to error.
      if packaging.version.parse(
          self._client_ray_version
      ) > packaging.version.parse("2.0"):
          self._check_connection_and_version(
              min_version="2.0",
              version_error_message=f"Client Ray version {self._client_ray_version} "
              "is not compatible with the Ray cluster. Please ensure the cluster is "
              "running Ray 2.0 or higher or downgrade the client Ray version.",
          )
  
imports: import dataclasses
  import logging
  from typing import Any, Dict, Iterator, List, Optional, Union
  import ray
  import packaging.version
  from ray.dashboard.utils import get_address_for_submission_client
  from ray.dashboard.modules.job.utils import strip_keys_with_value_none
  from ray.dashboard.modules.job.pydantic_models import JobDetails
  from ray.dashboard.modules.job.common import JobDeleteResponse, JobStatus, JobSubmitRequest, JobSubmitResponse, JobStopResponse, JobLogsResponse
  from ray.dashboard.modules.dashboard_sdk import SubmissionClient
  from ray.runtime_env import RuntimeEnv
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 1 to create a new JobSubmissionClient object from inherited base classes: SubmissionClient with example: obj = JobSubmissionClient(address, create_cluster_if_needed, cookies, metadata, headers, verify)