class_docstr: Utility Class to help with the selection of the 'best' model
  during hypersearch for a particular job.
  
  The main interface method is updateResultsForJob(), which is to
  be called periodically from the hypersearch worker.
  
  When called, the model chooser first tries to update the
  _eng_last_selection_sweep_time field in the jobs table. If it
  is successful, it then tries to find the model with the maximum
  metric.
  
  Note : Altough that there are many model choosers for a
  given job, only 1 will update the results because only one
  chooser will be  able to update the _eng_last_selection_sweep_time
  within a given interval
docstr: Chooses the best model for a given job.
  
  Parameters
  -----------------------------------------------------------------------
  forceUpdate:  (True/False). If True, the update will ignore all the
                restrictions on the minimum time to update and the minimum
                number of records to update. This should typically only be
                set to true if the model has completed running
docstr_tok: ["Chooses","the","best","model","for","a","given","job",".","Parameters","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","-","forceUpdate",":","(","True\/False",")",".","If","True",",","the","update","will","ignore","all","the","restrictions","on","the","minimum","time","to","update","and","the","minimum","number","of","records","to","update",".","This","should","typically","only","be","set","to","true","if","the","model","has","completed","running"]
code: def updateResultsForJob(self, forceUpdate=True):
      """Chooses the best model for a given job.
  
      Parameters
      -----------------------------------------------------------------------
      forceUpdate:  (True/False). If True, the update will ignore all the
                    restrictions on the minimum time to update and the minimum
                    number of records to update. This should typically only be
                    set to true if the model has completed running
      """
      updateInterval = time.time() - self._lastUpdateAttemptTime
      if updateInterval < self._MIN_UPDATE_INTERVAL and not forceUpdate:
          return
  
      self.logger.info(
          "Attempting model selection for jobID=%d: time=%f"
          "  lastUpdate=%f"
          % (self._jobID, time.time(), self._lastUpdateAttemptTime)
      )
  
      timestampUpdated = self._cjDB.jobUpdateSelectionSweep(
          self._jobID, self._MIN_UPDATE_INTERVAL
      )
      if not timestampUpdated:
          self.logger.info(
              "Unable to update selection sweep timestamp: jobID=%d"
              " updateTime=%f"
              % (self._jobID, self._lastUpdateAttemptTime)
          )
          if not forceUpdate:
              return
  
      self._lastUpdateAttemptTime = time.time()
      self.logger.info(
          "Succesfully updated selection sweep timestamp jobid=%d updateTime=%f"
          % (self._jobID, self._lastUpdateAttemptTime)
      )
  
      minUpdateRecords = self._MIN_UPDATE_THRESHOLD
  
      jobResults = self._getJobResults()
      if forceUpdate or jobResults is None:
          minUpdateRecords = 0
  
      candidateIDs, bestMetric = self._cjDB.modelsGetCandidates(
          self._jobID, minUpdateRecords
      )
  
      self.logger.info(
          "Candidate models=%s, metric=%s, jobID=%s"
          % (candidateIDs, bestMetric, self._jobID)
      )
  
      if len(candidateIDs) == 0:
          return
  
      self._jobUpdateCandidate(
          candidateIDs[0], bestMetric, results=jobResults
      )
  
file_path: nupic-legacy/src/nupic/swarming/model_chooser.py
imports: import json
  import time
  import logging
  from nupic.support import initLogging
label_desc: Use image node_id 2 for calling the ModelChooser obj's underlying member method code with example usage: obj.updateResultsForJob(forceUpdate) without return types