class_docstr: Registers a session with a Sherpa Study via the port of the database.
  
  This function is called from trial-scripts only.
  
  Attributes:
      host (str): the host that runs the database. Passed host, host set via
          environment variable or 'localhost' in that order.
      port (int): port that database is running on. Passed port, port set via
          environment variable or 27010 in that order.
class_docstr_tok: ["Registers","a","session","with","a","Sherpa","Study","via","the","port","of","the","database",".","This","function","is","called","from","trial-scripts","only",".","Attributes",":","host","(","str",")",":","the","host","that","runs","the","database",".","Passed","host",",","host","set","via","environment","variable","or","'localhost","'","in","that","order",".","port","(","int",")",":","port","that","database","is","running","on",".","Passed","port",",","port","set","via","environment","variable","or","27010","in","that","order","."]
docstr: Args:
      host (str): the host that runs the database. Generally not needed since
          the scheduler passes the DB-host as an environment variable.
      port (int): port that database is running on. Generally not needed since
          the scheduler passes the DB-port as an environment variable.
      test_mode (bool): mock the client, that is, get_trial returns a trial
          that is empty, keras_send_metrics accepts calls but does not do any-
          thing, as does send_metrics. Useful for trial script debugging.
docstr_tok: ["Args",":","host","(","str",")",":","the","host","that","runs","the","database",".","Generally","not","needed","since","the","scheduler","passes","the","DB-host","as","an","environment","variable",".","port","(","int",")",":","port","that","database","is","running","on",".","Generally","not","needed","since","the","scheduler","passes","the","DB-port","as","an","environment","variable",".","test_mode","(","bool",")",":","mock","the","client",",","that","is",",","get_trial","returns","a","trial","that","is","empty",",","keras_send_metrics","accepts","calls","but","does","not","do","any-","thing",",","as","does","send_metrics",".","Useful","for","trial","script","debugging","."]
code: def __init__(
      self, host=None, port=None, test_mode=False, **mongo_client_args
  ):
      """
      Args:
          host (str): the host that runs the database. Generally not needed since
              the scheduler passes the DB-host as an environment variable.
          port (int): port that database is running on. Generally not needed since
              the scheduler passes the DB-port as an environment variable.
          test_mode (bool): mock the client, that is, get_trial returns a trial
              that is empty, keras_send_metrics accepts calls but does not do any-
              thing, as does send_metrics. Useful for trial script debugging.
      """
      self.test_mode = test_mode
      if not self.test_mode:
          host = host or os.environ.get("SHERPA_DB_HOST") or "localhost"
          port = port or os.environ.get("SHERPA_DB_PORT") or 27010
          self.client = MongoClient(
              host, int(port), **mongo_client_args
          )
          self.db = self.client.sherpa
  
imports: import logging
  import numpy
  import pymongo
  from pymongo import MongoClient
  import subprocess
  import time
  import os
  import socket
  import warnings
  import sherpa
label_desc: Use image node_id 1 to create a new Client object from inherited base classes: object with example: obj = Client(host, port, test_mode)