Skip to content

Commit fae81df

Browse files
Add extension and config to enable templating in versions (#143)
* Add extension and config to enable tamplting in versions * Template in RAPIDS version * Add example
1 parent bcd8ccd commit fae81df

File tree

23 files changed

+178
-110
lines changed

23 files changed

+178
-110
lines changed

.github/workflows/build-and-deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
environment-file: conda/environments/deployment_docs.yml
3131

3232
- name: Build
33+
env:
34+
DEPLOYMENT_DOCS_BUILD_STABLE: ${{ startsWith(github.event.ref, 'refs/tags/') && 'true' || 'false' }}
3335
run: make html
3436

3537
# If on main in the upstream repo then push to docs repo

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,33 @@ This repository is continuously deployed to the [nightly docs at docs.rapids.ai]
102102

103103
We can also update the [stable documentation at docs.rapids.ai](https://docs.rapids.ai/deployment/stable/) by creating and pushing a tag which will cause the `build-and-deploy` workflow to push to the [`deployment/stable` subdirectory](https://github.com/rapidsai/docs/tree/gh-pages/deployment) instead.
104104

105+
The RAPIDS versions for things like container images and install instructions are templated into the documentation pages and are stored in `source/conf.py`.
106+
107+
```python
108+
versions = {
109+
"stable": {
110+
"rapids_container": "rapidsai/rapidsai-core:22.12-cuda11.5-runtime-ubuntu20.04-py3.9",
111+
},
112+
"nightly": {
113+
"rapids_container": "rapidsai/rapidsai-core-nightly:23.02-cuda11.5-runtime-ubuntu20.04-py3.9",
114+
},
115+
}
116+
```
117+
118+
You can then use the value in any documentation page or notebook like this.
119+
120+
```markdown
121+
# My doc page
122+
123+
The latest container image is {{ rapids_container }}.
124+
```
125+
126+
All builds will use the nightly section by default which allows you to test with the latest and greatest containers when developing locally or previewing nightly docs builds. To build the docs using the stable images you need to set the environment variable `DEPLOYMENT_DOCS_BUILD_STABLE` to `true`. This is done automatically when building from a tag in CI.
127+
128+
Before you publish a new version for a release ensure that the latest container images are available and then update the `stable` config to use the new release version and update `nightly` to use the next upcoming nightly.
129+
130+
Then you can push a tag to release.
131+
105132
```bash
106133
# Set next version number
107134
# See https://docs.rapids.ai/resources/versions/ and past releases for version scheme
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
def version_template(app, docname, source):
2+
"""Substitute versions into each page.
3+
4+
This allows documentation pages and notebooks to substiture in values like
5+
the latest container image using jinja2 syntax.
6+
7+
E.g
8+
9+
# My doc page
10+
11+
The latest container image is {{ rapids_container }}.
12+
13+
"""
14+
15+
# Make sure we're outputting HTML
16+
if app.builder.format != "html":
17+
return
18+
src = source[0]
19+
rendered = app.builder.templates.render_string(src, app.config.rapids_version)
20+
source[0] = rendered
21+
22+
23+
def setup(app):
24+
app.add_config_value("rapids_version", {}, "html")
25+
app.connect("source-read", version_template)
26+
27+
return {
28+
"version": "0.1",
29+
"parallel_read_safe": True,
30+
"parallel_write_safe": True,
31+
}

source/_includes/install-rapids-with-docker.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ On the release selector choose **Docker** in the **Method** column.
66
Then copy the commands shown:
77

88
```bash
9-
docker pull rapidsai/rapidsai-core:22.12-cuda11.5-runtime-ubuntu20.04-py3.9
9+
docker pull {{ rapids_container }}
1010
docker run --gpus all --rm -it \
1111
--shm-size=1g --ulimit memlock=-1 \
1212
-p 8888:8888 -p 8787:8787 -p 8786:8786 \
13-
rapidsai/rapidsai-core:22.12-cuda11.5-runtime-ubuntu20.04-py3.9
13+
{{ rapids_container }}
1414
```

source/cloud/aws/ec2-multi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ from dask_cloudprovider.aws import EC2Cluster
3535

3636
cluster = EC2Cluster(
3737
instance_type="g4dn.12xlarge", # 4 T4 GPUs
38-
docker_image="rapidsai/rapidsai-core:22.12-cuda11.5-runtime-ubuntu20.04-py3.9",
38+
docker_image="{{ rapids_container }}",
3939
worker_class="dask_cuda.CUDAWorker",
4040
worker_options={"rmm-managed-memory": True},
4141
security_groups=["<SECURITY GROUP ID>"],

source/cloud/aws/sagemaker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ set -e
3131

3232
sudo -u ec2-user -i <<'EOF'
3333
34-
mamba create -y -n rapids -c rapidsai -c conda-forge -c nvidia rapids=22.12 python=3.9 cudatoolkit=11.5 ipykernel
34+
mamba create -y -n rapids {{ rapids_conda_channels }} {{ rapids_conda_packages }} ipykernel
3535
conda activate rapids
3636
3737
# optionally install AutoGluon for AutoML GPU demo

source/cloud/azure/azure-vm-multi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ cluster = AzureVMCluster(
3838
disk_size=100,
3939
n_workers=2,
4040
worker_class="dask_cuda.CUDAWorker",
41-
docker_image="rapidsai/rapidsai-core:22.12-cuda11.5-runtime-ubuntu20.04-py3.9",
41+
docker_image={{rapids_container}},
4242
docker_args="-e DISABLE_JUPYTER=true -p 8787:8787 -p 8786:8786",
4343
)
4444
```

source/cloud/gcp/vertex-ai.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ For new, user-managed notebooks, it is recommended to use a RAPIDS docker image
99
Before configuring a new notebook, the [RAPIDS Docker image](#rapids-docker) will need to be built to expose port 8080 to be used as a notebook service.
1010

1111
```dockerfile
12-
FROM rapidsai/rapidsai-core:22.12-cuda11.5-runtime-ubuntu20.04-py3.9
12+
FROM {{ rapids_container }}
1313
EXPOSE 8080
1414

1515
ENTRYPOINT ["jupyter-lab", "--allow-root", "--ip=0.0.0.0", "--port=8080", "--no-browser", "--NotebookApp.token=''", "--NotebookApp.allow_origin='*'"]
@@ -18,8 +18,8 @@ ENTRYPOINT ["jupyter-lab", "--allow-root", "--ip=0.0.0.0", "--port=8080", "--no-
1818
Once you have built this image, it needs to be pushed to [Google Container Registry](https://cloud.google.com/container-registry/docs/pushing-and-pulling) for Vertex AI to access.
1919

2020
```console
21-
$ docker build -t gcr.io/<project>/<folder>/rapidsai-core:22.12-cuda11.5-runtime-ubuntu20.04-py3.9 .
22-
$ docker push gcr.io/<project>/<folder>/rapidsai-core:22.12-cuda11.5-runtime-ubuntu20.04-py3.9
21+
$ docker build -t gcr.io/<project>/<folder>/{{ rapids_container.replace('rapidsai/', '') }} .
22+
$ docker push gcr.io/<project>/<folder>/{{ rapids_container.replace('rapidsai/', '') }}
2323
```
2424

2525
## Create a New Notebook

source/conf.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@
2020
copyright = f"{datetime.date.today().year}, NVIDIA"
2121
author = "NVIDIA"
2222

23+
versions = {
24+
"stable": {
25+
"rapids_container": "rapidsai/rapidsai-core:22.12-cuda11.5-runtime-ubuntu20.04-py3.9",
26+
"rapids_conda_channels": "-c rapidsai -c conda-forge -c nvidia",
27+
"rapids_conda_packages": "rapids=22.12 python=3.9 cudatoolkit=11.5",
28+
},
29+
"nightly": {
30+
"rapids_container": "rapidsai/rapidsai-core-nightly:23.02-cuda11.5-runtime-ubuntu20.04-py3.9",
31+
"rapids_conda_channels": "-c rapidsai-nightly -c conda-forge -c nvidia",
32+
"rapids_conda_packages": "rapids=23.02 python=3.9 cudatoolkit=11.5",
33+
},
34+
}
35+
rapids_version = (
36+
versions["stable"]
37+
if os.environ.get("DEPLOYMENT_DOCS_BUILD_STABLE", "false") == "true"
38+
else versions["nightly"]
39+
)
2340

2441
# -- General configuration ---------------------------------------------------
2542

@@ -36,6 +53,7 @@
3653
"rapids_notebook_files",
3754
"rapids_related_examples",
3855
"rapids_grid_toctree",
56+
"rapids_version_templating",
3957
]
4058

4159
myst_enable_extensions = ["colon_fence"]

source/examples/rapids-sagemaker-higgs/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# FROM rapidsai/rapidsai-cloud-ml:latest
2-
FROM rapidsai/rapidsai-core:22.12-cuda11.5-runtime-ubuntu20.04-py3.9
1+
ARG RAPIDS_IMAGE
2+
3+
FROM $RAPIDS_IMAGE as rapids
34

45
RUN apt-get update && apt-get install -y --no-install-recommends build-essential
56

0 commit comments

Comments
 (0)