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: Sends metrics for a trial to database.
  
  Args:
      trial (sherpa.core.Trial): trial to send metrics for.
      iteration (int): the iteration e.g. epoch the metrics are for.
      objective (float): the objective value.
      context (dict): other metric-values.
docstr_tok: ["Sends","metrics","for","a","trial","to","database",".","Args",":","trial","(","sherpa.core.Trial",")",":","trial","to","send","metrics","for",".","iteration","(","int",")",":","the","iteration","e.g",".","epoch","the","metrics","are","for",".","objective","(","float",")",":","the","objective","value",".","context","(","dict",")",":","other","metric-values","."]
code: def send_metrics(self, trial, iteration, objective, context={}):
      """
      Sends metrics for a trial to database.
  
      Args:
          trial (sherpa.core.Trial): trial to send metrics for.
          iteration (int): the iteration e.g. epoch the metrics are for.
          objective (float): the objective value.
          context (dict): other metric-values.
      """
      if self.test_mode:
          return
  
      result = {
          "parameters": trial.parameters,
          "trial_id": trial.id,
          "objective": objective,
          "iteration": iteration,
          "context": context,
      }
      # Convert float32 to float64.
      # Note: Keras ReduceLROnPlateau callback requires this.
      for k, v in context.items():
          if type(v) == numpy.float32:
              context[k] = numpy.float64(v)
  
      self.db.results.insert_one(result)
  
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 3 for calling the Client obj's underlying member method code with example usage: obj.send_metrics(trial, iteration, objective, context) without return types