-
Notifications
You must be signed in to change notification settings - Fork 321
176 lines (153 loc) · 6.61 KB
/
docs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# This workflow builds the torchrl docs and deploys them to gh-pages.
name: Generate documentation
on:
push:
branches:
- nightly
- main
- release/*
tags:
- v[0-9]+.[0-9]+.[0-9]
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
pull_request:
workflow_dispatch:
concurrency:
# Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers, so using ${{ github.ref }}.
# On master, we want all builds to complete even if merging happens faster to make it easier to discover at which point something broke.
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && format('ci-master-{0}', github.sha) || format('ci-{0}', github.ref) }}
cancel-in-progress: true
jobs:
build-docs:
strategy:
matrix:
python_version: ["3.10"]
cuda_arch_version: ["12.1"]
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
with:
repository: pytorch/rl
upload-artifact: docs
timeout: 120
script: |
set -e
set -v
# apt-get update && apt-get install -y -f git wget gcc g++ dialog apt-utils
yum makecache
# yum install -y glfw glew mesa-libGL mesa-libGL-devel mesa-libOSMesa-devel egl-utils freeglut
# Install Mesa and OpenGL Libraries:
yum install -y glfw mesa-libGL mesa-libGL-devel egl-utils freeglut mesa-libGLU mesa-libEGL
# Install DRI Drivers:
yum install -y mesa-dri-drivers
# Install Xvfb for Headless Environments:
yum install -y xorg-x11-server-Xvfb
# xhost +local:docker
# Xvfb :1 -screen 0 1024x768x24 &
# export DISPLAY=:1
root_dir="$(pwd)"
conda_dir="${root_dir}/conda"
env_dir="${root_dir}/env"
os=Linux
# 1. Install conda at ./conda
printf "* Installing conda\n"
wget -O miniconda.sh "http://repo.continuum.io/miniconda/Miniconda3-latest-${os}-x86_64.sh"
bash ./miniconda.sh -b -f -p "${conda_dir}"
eval "$(${conda_dir}/bin/conda shell.bash hook)"
printf "* Creating a test environment\n"
conda create --prefix "${env_dir}" -y python=3.10
printf "* Activating\n"
conda activate "${env_dir}"
# 2. upgrade pip, ninja and packaging
# apt-get install python3-pip unzip -y -f
python3 -m pip install --upgrade pip
python3 -m pip install setuptools ninja packaging cmake -U
# 3. check python version
python3 --version
# 4. Check git version
git version
# 5. Install PyTorch
python3 -m pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu -U --quiet --root-user-action=ignore
# 6. Install tensordict
python3 -m pip install git+https://github.com/pytorch/tensordict.git --quiet --root-user-action=ignore
# 7. Install TorchRL
python3 setup.py develop
# 8. Install requirements
python3 -m pip install -r docs/requirements.txt --quiet --root-user-action=ignore
# 9. Set sanitize version
if [[ ${{ github.event_name }} == push && (${{ github.ref_type }} == tag || (${{ github.ref_type }} == branch && ${{ github.ref_name }} == release/*)) ]]; then
echo '::group::Enable version string sanitization'
# This environment variable just has to exist and must not be empty. The actual value is arbitrary.
# See docs/source/conf.py for details
export RL_SANITIZE_VERSION_STR_IN_DOCS=1
echo '::endgroup::'
fi
# 10. Test torchrl installation
mkdir _tmp
cd _tmp
PYOPENGL_PLATFORM=egl MUJOCO_GL=egl python3 -c """from torchrl.envs.libs.dm_control import DMControlEnv
print(DMControlEnv('cheetah', 'run', from_pixels=True).reset())"""
cd ..
# 11. Build doc
cd ./docs
# timeout 7m bash -ic "MUJOCO_GL=egl sphinx-build ./source _local_build" || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi
# bash -ic "PYOPENGL_PLATFORM=egl MUJOCO_GL=egl sphinx-build ./source _local_build" || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi
PYOPENGL_PLATFORM=egl MUJOCO_GL=egl TORCHRL_CONSOLE_STREAM=stdout sphinx-build ./source _local_build
cd ..
cp -r docs/_local_build/* "${RUNNER_ARTIFACT_DIR}"
echo $(ls "${RUNNER_ARTIFACT_DIR}")
if [[ ${{ github.event_name == 'pull_request' }} ]]; then
cp -r docs/_local_build/* "${RUNNER_DOCS_DIR}"
fi
upload:
needs: build-docs
if: github.repository == 'pytorch/rl' && github.event_name == 'push' &&
((github.ref_type == 'branch' && github.ref_name == 'main') || github.ref_type == 'tag')
permissions:
contents: write
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
repository: pytorch/rl
download-artifact: docs
ref: gh-pages
test-infra-ref: main
script: |
set -euo pipefail
REF_TYPE=${{ github.ref_type }}
REF_NAME=${{ github.ref_name }}
if [[ "${REF_TYPE}" == branch ]]; then
if [[ "${REF_NAME}" == main ]]; then
TARGET_FOLDER="${REF_NAME}"
# Bebug:
# else
# TARGET_FOLDER="release-doc"
fi
elif [[ "${REF_TYPE}" == tag ]]; then
case "${REF_NAME}" in
*-rc*)
echo "Aborting upload since this is an RC tag: ${REF_NAME}"
exit 0
;;
*)
# Strip the leading "v" as well as the trailing patch version. For example:
# 'v0.15.2' -> '0.15'
TARGET_FOLDER=$(echo "${REF_NAME}" | sed 's/v\([0-9]\+\)\.\([0-9]\+\)\.[0-9]\+/\1.\2/')
;;
esac
fi
echo "Target Folder: ${TARGET_FOLDER}"
mkdir -p "${TARGET_FOLDER}"
rm -rf "${TARGET_FOLDER}"/*
echo $(ls "${RUNNER_ARTIFACT_DIR}")
rsync -a "${RUNNER_ARTIFACT_DIR}"/ "${TARGET_FOLDER}"
git add "${TARGET_FOLDER}" || true
# Debug
# if [[ "${TARGET_FOLDER}" == "main" ]] || [[ "${TARGET_FOLDER}" == "release-doc" ]]; then
if [[ "${TARGET_FOLDER}" == "main" ]] ; then
mkdir -p _static
rm -rf _static/*
cp -r "${TARGET_FOLDER}"/_static/* _static
git add _static || true
fi
git config user.name 'pytorchbot'
git config user.email '[email protected]'
git config http.postBuffer 524288000
git commit -m "auto-generating sphinx docs" || true
git push