docstr: convenience logger for 'semi-live-results'
  
  Logger that writes job results into two files (configs.json and results.json).
  Both files contain propper json objects in each line.
  
  This version opens and closes the files for each result.
  This might be very slow if individual runs are fast and the
  filesystem is rather slow (e.g. a NFS).
  
  Parameters
  ----------
  
  directory: string
          the directory where the two files 'configs.json' and
          'results.json' are stored
  overwrite: bool
          In case the files already exist, this flag controls the
          behavior:
          
                  * True:   The existing files will be overwritten. Potential risk of deleting previous results
                  * False:  A FileExistsError is raised and the files are not modified.
docstr_tok: ["convenience","logger","for","'semi-live-results'","Logger","that","writes","job","results","into","two","files","(","configs.json","and","results.json",")",".","Both","files","contain","propper","json","objects","in","each","line",".","This","version","opens","and","closes","the","files","for","each","result",".","This","might","be","very","slow","if","individual","runs","are","fast","and","the","filesystem","is","rather","slow","(","e.g",".","a","NFS",")",".","Parameters","--","--","--","--","--","directory",":","string","the","directory","where","the","two","files","'configs.json","'","and","'results.json","'","are","stored","overwrite",":","bool","In","case","the","files","already","exist",",","this","flag","controls","the","behavior",":","*","True",":","The","existing","files","will","be","overwritten",".","Potential","risk","of","deleting","previous","results","*","False",":","A","FileExistsError","is","raised","and","the","files","are","not","modified","."]
code: def __init__(self, directory, overwrite=False):
      """
      convenience logger for 'semi-live-results'
  
      Logger that writes job results into two files (configs.json and results.json).
      Both files contain propper json objects in each line.
  
      This version opens and closes the files for each result.
      This might be very slow if individual runs are fast and the
      filesystem is rather slow (e.g. a NFS).
  
      Parameters
      ----------
  
      directory: string
              the directory where the two files 'configs.json' and
              'results.json' are stored
      overwrite: bool
              In case the files already exist, this flag controls the
              behavior:
  
                      * True:   The existing files will be overwritten. Potential risk of deleting previous results
                      * False:  A FileExistsError is raised and the files are not modified.
      """
  
      os.makedirs(directory, exist_ok=True)
  
      self.config_fn = os.path.join(directory, "configs.json")
      self.results_fn = os.path.join(directory, "results.json")
  
      try:
          with open(self.config_fn, "x") as fh:
              pass
      except FileExistsError:
          if overwrite:
              with open(self.config_fn, "w") as fh:
                  pass
          else:
              raise FileExistsError(
                  "The file %s already exists." % self.config_fn
              )
      except:
          raise
  
      try:
          with open(self.results_fn, "x") as fh:
              pass
      except FileExistsError:
          if overwrite:
              with open(self.results_fn, "w") as fh:
                  pass
          else:
              raise FileExistsError(
                  "The file %s already exists." % self.config_fn
              )
  
      except:
          raise
  
      self.config_ids = set()
  
imports: import copy
  import os
  import json
  from hpbandster.core.base_iteration import Datum
label_desc: Use image node_id 1 to create a new json_result_logger object from inherited base classes: object with example: obj = json_result_logger(directory, overwrite)