docstr:    Provide credentials as arguments, as environment variables, or by providing a gremlinpython client
     Environment variable names are the same as the constructor argument names
     If no client provided, create (connect)
  
  **Example: Login and plot **
          ::
  
              import graphistry
              (graphistry
                  .cosmos(
                      COSMOS_ACCOUNT='a',
                      COSMOS_DB='b',
                      COSMOS_CONTAINER='c',
                      COSMOS_PRIMARY_KEY='d')
                  .gremlin('g.E().sample(10)')
                  .fetch_nodes()  # Fetch properties for nodes
                  .plot())
docstr_tok: ["Provide","credentials","as","arguments",",","as","environment","variables",",","or","by","providing","a","gremlinpython","client","Environment","variable","names","are","the","same","as","the","constructor","argument","names","If","no","client","provided",",","create","(","connect",")","*","*","Example",":","Login","and","plot","*","*",":",":","import","graphistry","(","graphistry",".cosmos","(","COSMOS_ACCOUNT=","'","a","'",",","COSMOS_DB=","'","b","'",",","COSMOS_CONTAINER=","'","c","'",",","COSMOS_PRIMARY_KEY='d","'",")",".gremlin","(","'","g.E","(",")",".sample","(","10",")","'",")",".fetch_nodes","(",")","#","Fetch","properties","for","nodes",".plot","(",")",")"]
code: def cosmos(
      self,
      COSMOS_ACCOUNT: Optional[str] = None,
      COSMOS_DB: Optional[str] = None,
      COSMOS_CONTAINER: Optional[str] = None,
      COSMOS_PRIMARY_KEY: Optional[str] = None,
      gremlin_client: Optional[Client] = None,
  ):
      """
         Provide credentials as arguments, as environment variables, or by providing a gremlinpython client
         Environment variable names are the same as the constructor argument names
         If no client provided, create (connect)
  
      **Example: Login and plot **
              ::
  
                  import graphistry
                  (graphistry
                      .cosmos(
                          COSMOS_ACCOUNT='a',
                          COSMOS_DB='b',
                          COSMOS_CONTAINER='c',
                          COSMOS_PRIMARY_KEY='d')
                      .gremlin('g.E().sample(10)')
                      .fetch_nodes()  # Fetch properties for nodes
                      .plot())
  
      """
  
      ensure_imports()
  
      self.COSMOS_ACCOUNT = (
          COSMOS_ACCOUNT
          if COSMOS_ACCOUNT is not None
          else os.environ["COSMOS_ACCOUNT"]
      )
      self.COSMOS_DB = (
          COSMOS_DB
          if COSMOS_DB is not None
          else os.environ["COSMOS_DB"]
      )
      self.COSMOS_CONTAINER = (
          COSMOS_CONTAINER
          if COSMOS_CONTAINER is not None
          else os.environ["COSMOS_CONTAINER"]
      )
      self.COSMOS_PRIMARY_KEY = (
          COSMOS_PRIMARY_KEY
          if COSMOS_PRIMARY_KEY is not None
          else os.environ["COSMOS_PRIMARY_KEY"]
      )
      self._gremlin_client = gremlin_client
  
      def connect(self: CosmosMixin) -> CosmosMixin:
          if self._gremlin_client is not None:
              self._gremlin_client.close()
  
          self._gremlin_client = Client(
              f"wss://{self.COSMOS_ACCOUNT}.gremlin.cosmosdb.azure.com:443/",
              "g",
              username=f"/dbs/{self.COSMOS_DB}/colls/{self.COSMOS_CONTAINER}",
              password=self.COSMOS_PRIMARY_KEY,
              message_serializer=GraphSONSerializersV2d0(),
          )
          return self
  
      self._reconnect_gremlin: Optional[Callable[[CosmosMixin], CosmosMixin]] = connect  # type: ignore
  
      if gremlin_client is None:
          if self._reconnect_gremlin is None:
              raise ValueError("Missing _reconnect_gremlin")
          else:
              self._reconnect_gremlin(self)
  
      return self
  
imports: from typing import Any, Callable, Iterable, List, Optional, Set, Union, TYPE_CHECKING
  import os, pandas
  from .Plottable import Plottable
  from .util import setup_logger
label_desc: Use image node_id 2 for calling the CosmosMixin obj's underlying member method code with example usage: obj.cosmos(COSMOS_ACCOUNT, COSMOS_DB, COSMOS_CONTAINER, COSMOS_PRIMARY_KEY, gremlin_client) and returns: self, self