Skip to content

Commit

Permalink
added flush
Browse files Browse the repository at this point in the history
  • Loading branch information
williamFalcon committed Jul 26, 2019
1 parent a80ed76 commit 8989b3c
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions test_tube/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,12 @@ def get_tensorboardx_scalars_path(self, exp_name, exp_version):
def _get_file_writer(self):
"""Returns the default FileWriter instance. Recreates it if closed."""
if self.rank > 0:
return
return TTDummyFileWriter()

if self.all_writers is None or self.file_writer is None:
if 'purge_step' in self.kwargs.keys():
most_recent_step = self.kwargs.pop('purge_step')
self.file_writer = TTFileWriter(logdir=self.log_dir, **self.kwargs)
self.file_writer = FileWriter(logdir=self.log_dir, **self.kwargs)
self.file_writer.debug = self.debug
self.file_writer.rank = self.rank

Expand Down Expand Up @@ -518,12 +519,7 @@ def flush(self):
writer.flush()


class TTFileWriter(FileWriter):

def __init__(self, *args, **kwargs):
FileWriter(self).__init__(*args, **kwargs)
self.debug = False
self.rank = 0
class TTDummyFileWriter(object):

def add_summary(self, summary, global_step=None, walltime=None):
"""
Expand All @@ -534,11 +530,7 @@ def add_summary(self, summary, global_step=None, walltime=None):
:param walltime:
:return:
"""
# don't log when rank > 0
if self.debug or self.rank > 0: return

# otherwise do the normal thing
super().add_summary(self, summary, global_step=global_step, walltime=walltime)
return



Expand Down

0 comments on commit 8989b3c

Please sign in to comment.