Skip to content

Commit

Permalink
Rank variable not set in else statement for logging. (#451)
Browse files Browse the repository at this point in the history
* rank variable not set in else statement for logging.

* Only call mpi get rank once

* Update changelog
  • Loading branch information
keshaviyengar authored and araffin committed Aug 29, 2019
1 parent 1d55747 commit 51285cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/misc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Bug Fixes:
where OpenMPI would cause stable-baselines to hang on Ubuntu installs.
See :ref:`installation notes <openmpi>` and
`Issue #430 <https://github.com/hill-a/stable-baselines/issues/430>`.
- Fix a bug when calling `logger.configure()` with MPI enabled (@keshaviyengar)

Deprecations:
^^^^^^^^^^^^^
Expand Down
3 changes: 2 additions & 1 deletion stable_baselines/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,11 @@ def configure(folder=None, format_strs=None):
folder = os.path.join(tempfile.gettempdir(), datetime.datetime.now().strftime("openai-%Y-%m-%d-%H-%M-%S-%f"))
assert isinstance(folder, str)
os.makedirs(folder, exist_ok=True)
rank = mpi_rank_or_zero()

log_suffix = ''
if format_strs is None:
if mpi_rank_or_zero() == 0:
if rank == 0:
format_strs = os.getenv('OPENAI_LOG_FORMAT', 'stdout,log,csv').split(',')
else:
log_suffix = "-rank%03i" % rank
Expand Down

0 comments on commit 51285cc

Please sign in to comment.