Skip to content

Commit

Permalink
[Doc] Publishing on pytorch.org (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmoens committed Oct 18, 2022
1 parent 94774b2 commit f8ebf33
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 114 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Generate documentation
on:
push:
branches:
- main
- docs
workflow_dispatch:
jobs:
build_docs_job:
Expand All @@ -12,7 +12,7 @@ jobs:
matrix:
include:
- os: linux.2xlarge
python-version: 3.7
python-version: 3.8
steps:
- name: Check ldd --version
run: ldd --version
Expand All @@ -26,8 +26,13 @@ jobs:
sudo pip3 install --upgrade pip
- name: Setup conda
run: |
rm -rf $HOME/miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
- name: Install gcc
shell: bash
run: |
sudo yum group install -y "Development Tools"
- name: setup Path
run: |
echo "/home/ec2-user/miniconda/bin" >> $GITHUB_PATH
Expand All @@ -51,12 +56,15 @@ jobs:
conda run -n build_binary python -m pip install --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
- name: Install TorchRL
run: |
conda run -n build_binary python -m pip install torchrl-nightly
conda run -n build_binary python -m pip install -e .
- name: Test torchrl installation
shell: bash
run: |
mkdir _tmp
cd _tmp
conda run -n build_binary \
python -c "import torchrl"
cd ..
- name: Build the docset
run: |
conda run -n build_binary python -m pip install -r docs/requirements.txt
Expand All @@ -70,4 +78,4 @@ jobs:
with:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: docs/build/html # The folder the action should deploy.
FOLDER: docs/build/html # The folder the action should deploy.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![pytorch](https://circleci.com/gh/pytorch/rl.svg?style=shield)](https://circleci.com/gh/pytorch/rl)
[![Documentation](https://img.shields.io/badge/Documentation-blue.svg)](https://www.pytorch.org/rl/)
[![codecov](https://codecov.io/gh/pytorch/rl/branch/main/graph/badge.svg?token=HcpK1ILV6r)](https://codecov.io/gh/pytorch/rl)
[![Twitter Follow](https://img.shields.io/twitter/follow/torchrl1?style=social)](https://twitter.com/torchrl1)
[![Python 3.7, 3.8](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10-blue.svg)](https://www.python.org/downloads/)
Expand Down
5 changes: 5 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ numpy
sphinx-copybutton>=0.3.1
sphinx-gallery>=0.9.0
sphinx==3.5.4
Jinja2==3.0.1
sphinx-autodoc-typehints
sphinx-serve
git+https://github.com/vmoens/aafig@4319769eae88fff8e3464858f3cf8c277f35335d
sphinxcontrib-htmlhelp
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
4 changes: 4 additions & 0 deletions docs/source/_static/css/custom_torchrl.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
article.pytorch-article .sphx-glr-download-link-note.admonition.note,
article.pytorch-article .reference.download.internal, article.pytorch-article .sphx-glr-signature {
display: block;
}
Binary file added docs/source/_static/img/pytorch-logo-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions docs/source/_static/img/pytorch-logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/img/pytorch-logo-flame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions docs/source/_static/img/pytorch-logo-flame.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 3 additions & 98 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
import torchrl

project = "torchrl"
copyright = "2022-presennt, Torch Contributors"
copyright = "2022, Meta"
author = "Torch Contributors"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = "main (" + torchrl.__version__ + " )"
version = "main (" + str(torchrl.__version__) + " )"
# The full version, including alpha/beta/rc tags.
# TODO: verify this works as expected
release = "main"
Expand All @@ -53,17 +53,11 @@
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.coverage",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinx.ext.duration",
"sphinx.ext.autosectionlabel",
"sphinx_gallery.gen_gallery",
"sphinx_autodoc_typehints",
"sphinxcontrib.aafig",
]

Expand Down Expand Up @@ -105,15 +99,6 @@
html_theme = "pytorch_sphinx_theme"
html_theme_path = [pytorch_sphinx_theme.get_html_theme_path()]

html_theme_options = {
"collapse_navigation": False,
"display_version": True,
"logo_only": True,
"pytorch_project": "docs",
"navigation_with_keys": True,
"analytics_id": "UA-117752657-2",
}

# Output file base name for HTML help builder.
htmlhelp_basename = "PyTorchdoc"

Expand All @@ -125,28 +110,7 @@
html_static_path = ["_static"]

# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}


# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
# latex_documents = [
# (master_doc, "pytorch.tex", "torchrl Documentation", "Torch Contributors", "manual"),
# ]
latex_elements = {}


# -- Options for manual page output ---------------------------------------
Expand Down Expand Up @@ -182,63 +146,4 @@
}


from docutils import nodes
from sphinx import addnodes
from sphinx.util.docfields import TypedField


def patched_make_field(self, types, domain, items, **kw):
# `kw` catches `env=None` needed for newer sphinx while maintaining
# backwards compatibility when passed along further down!

# type: (list, unicode, tuple) -> nodes.field # noqa: F821
def handle_item(fieldarg, content):
par = nodes.paragraph()
par += addnodes.literal_strong("", fieldarg) # Patch: this line added
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
# addnodes.literal_strong))
if fieldarg in types:
par += nodes.Text(" (")
# NOTE: using .pop() here to prevent a single type node to be
# inserted twice into the doctree, which leads to
# inconsistencies later when references are resolved
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = "".join(n.astext() for n in fieldtype)
typename = typename.replace("int", "python:int")
typename = typename.replace("long", "python:long")
typename = typename.replace("float", "python:float")
typename = typename.replace("type", "python:type")
par.extend(
self.make_xrefs(
self.typerolename,
domain,
typename,
addnodes.literal_emphasis,
**kw
)
)
else:
par += fieldtype
par += nodes.Text(")")
par += nodes.Text(" -- ")
par += content
return par

fieldname = nodes.field_name("", self.label)
if len(items) == 1 and self.can_collapse:
fieldarg, content = items[0]
bodynode = handle_item(fieldarg, content)
else:
bodynode = self.list_type()
for fieldarg, content in items:
bodynode += nodes.list_item("", handle_item(fieldarg, content))
fieldbody = nodes.field_body("", bodynode)
return nodes.field("", fieldname, fieldbody)


TypedField.make_field = patched_make_field

aafig_default_options = dict(scale=1.5, aspect=1.0, proportional=True)

coverage_show_missing_items = True
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
TorchRL
=======
Welcome to the TorchRL Documentation!
=====================================

TorchRL is an open-source Reinforcement Learning (RL) library for PyTorch.

Expand Down
20 changes: 10 additions & 10 deletions docs/source/reference/objectives.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ Returns
:toctree: generated/
:template: rl_template_noinherit.rst

GAE
TDLambdaEstimate
TDEstimate
functional.generalized_advantage_estimate
functional.vec_generalized_advantage_estimate
functional.vec_td_lambda_return_estimate
functional.vec_td_lambda_advantage_estimate
functional.td_lambda_return_estimate
functional.td_lambda_advantage_estimate
functional.td_advantage_estimate
value.GAE
value.TDLambdaEstimate
value.TDEstimate
value.functional.generalized_advantage_estimate
value.functional.vec_generalized_advantage_estimate
value.functional.vec_td_lambda_return_estimate
value.functional.vec_td_lambda_advantage_estimate
value.functional.td_lambda_return_estimate
value.functional.td_lambda_advantage_estimate
value.functional.td_advantage_estimate


Utils
Expand Down
1 change: 1 addition & 0 deletions torchrl/objectives/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
distance_loss,
hold_out_params,
next_state_value,
hold_out_net,
)
from .value import bellman_max, c_val, dv_val, vtrace, GAE, TDLambdaEstimate, TDEstimate

0 comments on commit f8ebf33

Please sign in to comment.