Skip to content

Commit

Permalink
backward support for log_dir (#463)
Browse files Browse the repository at this point in the history
* backward support for log_dir

* add test
  • Loading branch information
lanpa committed Jul 4, 2019
1 parent 0a230d9 commit 9502862
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tensorboardX/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class SummaryWriter(object):
"""

def __init__(self, logdir=None, comment='', purge_step=None, max_queue=10,
flush_secs=120, filename_suffix='', write_to_disk=True, **kwargs):
flush_secs=120, filename_suffix='', write_to_disk=True, log_dir=None, **kwargs):
"""Creates a `SummaryWriter` that will write out events and summaries
to the event file.
Expand Down Expand Up @@ -235,6 +235,8 @@ def __init__(self, logdir=None, comment='', purge_step=None, max_queue=10,
# folder location: runs/May04_22-14-54_s-MacBook-Pro.localLR_0.1_BATCH_16/
"""
if log_dir is not None and logdir is None:
logdir = log_dir
if not logdir:
import socket
from datetime import datetime
Expand Down
4 changes: 4 additions & 0 deletions tests/test_summary_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def test_summary_writer_ctx(self):
writer.add_scalar('test', 1)
assert writer.file_writer is None

def test_summary_writer_backcomapt(self):
with SummaryWriter(log_dir='/tmp/tbxtest') as writer:
writer.add_scalar('test', 1)

def test_summary_writer_close(self):
# Opening and closing SummaryWriter a lot should not run into
# OSError: [Errno 24] Too many open files
Expand Down

1 comment on commit 9502862

@corbyrosset
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks this was causing problems for me

Please sign in to comment.