Skip to content

Commit

Permalink
run code in browser (ray-project#22727)
Browse files Browse the repository at this point in the history
Example for running notebooks on our docs directly in the browser by connecting to a binder instance launched on demand.
If this seems useful we can extend this to other examples gradually.

Signed-off-by: Max Pumperla <max.pumperla@googlemail.com>
  • Loading branch information
maxpumperla authored Mar 2, 2022
1 parent 3e3db8e commit 7d4296c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions binder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Dependencies for mybinder.org

To run notebook examples directly in the browser with binder, we need to set up the right dependencies,
so that the launched notebook can import them right away.

The `requirements.txt` file contains dependencies for (most) of the notebooks in our documentation.
4 changes: 4 additions & 0 deletions binder/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Set up requirements needed to build a binder server to launch into.
-r ../doc/requirements-doc.txt
-r ../python/requirements.txt
ray[rllib, serve, tune]
1 change: 1 addition & 0 deletions doc/requirements-doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ sphinx-book-theme==0.1.7
sphinx-external-toc==0.2.3
sphinxcontrib.yt==0.2.2
sphinx-sitemap==2.2.0
sphinx-thebe==0.1.1

# MyST
myst-parser==0.15.2
Expand Down
8 changes: 8 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"sphinx.ext.doctest",
"sphinx.ext.coverage",
"sphinx_external_toc",
"sphinx_thebe",
]

myst_enable_extensions = [
Expand All @@ -51,6 +52,13 @@
"replacements",
]

# Thebe configuration for launching notebook cells within the docs.
thebe_config = {
"selector": "div.highlight",
"repository_url": "https://github.com/ray-project/ray",
"repository_branch": "master",
}

# Cache notebook outputs in _build/.jupyter_cache
# To prevent notebook execution, set this to "off". To force re-execution, set this to "force".
# To cache previous runs, set this to "cache".
Expand Down
4 changes: 4 additions & 0 deletions doc/source/tune/examples/tune-sklearn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
"``TuneGridSearchCV`` with a\n",
"[SGDClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDClassifier.html).\n",
"\n",
"\n",
"```{thebe-button} Activate code examples\n",
"```\n",
"\n",
"To start out, change the import statement to get tune-scikit-learn’s grid search cross validation interface:"
]
},
Expand Down

0 comments on commit 7d4296c

Please sign in to comment.