def __init__(self, logdir, max_queue_size=10, flush_secs=120, filename_suffix='', filename=''): self._logdir = logdir if not bfile.exists(logdir): bfile.makedirs(logdir) if filename: if 'vdlrecords' in filename: self._file_name = bfile.join(logdir, filename) if bfile.exists(self._file_name): print( '`{}` is exists, VisualDL will add logs to it.'.format( self._file_name)) else: fn = "vdlrecords.%010d.log%s" % (time.time(), filename_suffix) self._file_name = bfile.join(logdir, fn) print( 'Since the log filename should contain `vdlrecords`, the filename is invalid and `{}` will replace `{}`'.format( fn, filename)) else: self._file_name = bfile.join(logdir, "vdlrecords.%010d.log%s" % ( time.time(), filename_suffix)) self._general_file_writer = bfile.BFile(self._file_name, "wb") self._async_writer = _AsyncWriter(RecordWriter( self._general_file_writer), max_queue_size, flush_secs) # TODO(shenyuhan) Maybe file_version in future. # _record = record_pb2.Record() # self.add_record(_record) self.flush()
def __init__(self, filepath=None): if filepath is None: raise FileNotFoundError('No filename provided, cannot read Events') if not bfile.exists(filepath): raise FileNotFoundError( '{} does not point to valid Events file'.format(filepath)) self._curr_event = None self.file_handle = bfile.BFile(filepath, 'rb')
def model(self, model_path): self._model = model_path with bfile.BFile(model_path, 'rb') as bfp: if not bfp.isfile(model_path): print("Model path %s should be file path, please check this path." % model_path) else: if bfile.exists(model_path): self._model = model_path else: print("Model path %s is invalid, please check this path." % model_path)
def __init__(self, logdir, max_queue_size=10, flush_secs=120, filename_suffix=''): self._logdir = logdir if not bfile.exists(logdir): bfile.makedirs(logdir) self._file_name = bfile.join( logdir, "vdlrecords.%010d.log%s" % (time.time(), filename_suffix)) self._general_file_writer = bfile.BFile(self._file_name, "wb") self._async_writer = _AsyncWriter( RecordWriter(self._general_file_writer), max_queue_size, flush_secs) # TODO(shenyuhan) Maybe file_version in future. # _record = record_pb2.Record() # self.add_record(_record) self.flush()