Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
[ghstack-poisoned]
  • Loading branch information
vmoens committed Nov 13, 2024
1 parent 8ea65fb commit 97ab2e1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
version = f"main ({torchrl.__version__})"
release = "main"

os.environ["TORCHRL_CONSOLE_STREAM"] = "stdout"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
Expand Down Expand Up @@ -95,6 +97,7 @@
"abort_on_example_error": False,
"only_warn_on_example_error": True,
"show_memory": True,
"capture_repr": ("_repr_html_", "__repr__"), # capture representations
}

napoleon_use_ivar = True
Expand Down
12 changes: 11 additions & 1 deletion torchrl/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,17 @@
# Remove all attached handlers
while logger.hasHandlers():
logger.removeHandler(logger.handlers[0])
console_handler = logging.StreamHandler()
stream_handlers = {
"stdout": sys.stdout,
"stderr": sys.stderr,
}
TORCHRL_CONSOLE_STREAM = os.getenv("TORCHRL_CONSOLE_STREAM")
if TORCHRL_CONSOLE_STREAM:
stream_handler = stream_handlers[TORCHRL_CONSOLE_STREAM]
else:
stream_handler = None
console_handler = logging.StreamHandler(stream=stream_handler)

console_handler.setLevel(logging.INFO)
formatter = logging.Formatter("%(asctime)s [%(name)s][%(levelname)s] %(message)s")
console_handler.setFormatter(formatter)
Expand Down
6 changes: 6 additions & 0 deletions tutorials/sphinx-tutorials/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,12 @@
screen_obs = ale.getScreenRGB()
print("Observation from ALE simulator:", type(screen_obs), screen_obs.shape)

from matplotlib import pyplot as plt

plt.tick_params(left=False, bottom=False, labelleft=False, labelbottom=False)
plt.imshow(screen_obs)
plt.title("Screen rendering of Pong game.")

#####################################
# Exporting to ONNX is quite similar the Export/AOTI above:
#
Expand Down

0 comments on commit 97ab2e1

Please sign in to comment.