Skip to content

Commit

Permalink
Remove kernel_name argument from tutorials build scripts (#1977)
Browse files Browse the repository at this point in the history
Summary:
The `make_tutorials.py` script accepted a `kernel_name` argument but did nothing with it.

Pull Request resolved: #1977

Test Plan: `./scripts/make_docs.sh` on my laptop; I will check that the tutorials look as expected on the website.

Reviewed By: Balandat

Differential Revision: D51205173

Pulled By: esantorella

fbshipit-source-id: 6c80993745baffbfb595649dd32c255a77c7625e
  • Loading branch information
esantorella authored and facebook-github-bot committed Nov 10, 2023
1 parent f99740c commit 46418da
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
env:
DOCUSAURUS_PUBLISH_TOKEN: ${{ secrets.DOCUSAURUS_PUBLISH_TOKEN }}
run: |
bash scripts/publish_site.sh -d -k python3 -v ${{ github.event.release.tag_name }}
bash scripts/publish_site.sh -d -v ${{ github.event.release.tag_name }}
deploy:

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Additional details:

* This is the unversioned site built off of the current repository. Versioning is much more complex, and is generally not necessary for testing the site. Versioning is automatically handled when publishing the site to `gh-pages`.
* Skipping Sphinx API & tutorials: to build the site without running Sphinx or compiling the tutorials, pass the `-o` flag to the `make_docs.sh` script. This is especially useful when you want to iterate quickly on making changes to the Docusaurus config and you've already run Sphinx and tutorial generation (the outputs are still in `website` subdirectory and will be picked up).
* Tutorials: we embed tutorials written in Jupyter notebooks into the site. By default, these tutorials are converted to HTML without execution. However, you can execute all tutorials via `./scripts/make_docs.sh -t`, optionally specifying the Jupyter kernel to use via `-k [kernel_name]`. If you do execute the tutorials, please keep in mind that the version of Ax you have installed should match the version of Ax you're trying to build tutorials for.
* Tutorials: we embed tutorials written in Jupyter notebooks into the site. By default, these tutorials are converted to HTML without execution. However, you can execute all tutorials via `./scripts/make_docs.sh -t`. If you do execute the tutorials, please keep in mind that the version of Ax you have installed should match the version of Ax you're trying to build tutorials for.

### Publishing
The site is hosted as a GitHub page (on the `gh-pages` branch). We build the [latest version](https://ax.dev/versions/latest/index.html) of the site with every commit to the `main` branch via GitHub Actions. The latest version of the site can be manually updated using `./scripts/publish_site.sh` (assuming proper credentials).
Expand Down
13 changes: 2 additions & 11 deletions scripts/make_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,21 @@
set -e

usage() {
echo "Usage: $0 [-b] [-o] [-r] [-t] [-k kernel_name]"
echo "Usage: $0 [-b] [-o] [-r] [-t]"
echo ""
echo "Build Ax documentation. Must be executed from root of Ax repository."
echo ""
echo " -b Build static version of documentation (otherwise start server)."
echo " -o Only Docusaurus (skip Sphinx, tutorials). Useful when just make change to Docusaurus settings."
echo " -t Execute tutorials (instead of just converting)."
echo " -r Convert backtick-quoted class or function names in .md files into links to API documentation."
echo " -k Kernel name to use for executing tutorials. Use Jupyter default if not set."
echo ""
exit 1
}

BUILD_STATIC=false
ONLY_DOCUSAURUS=false
BUILD_TUTORIALS=false
KERNEL_NAME=false
INSERT_API_REFS=false

while getopts 'hbotrk:' flag; do
Expand All @@ -44,9 +42,6 @@ while getopts 'hbotrk:' flag; do
r)
INSERT_API_REFS=true
;;
k)
KERNEL_NAME=${OPTARG}
;;
*)
usage
;;
Expand Down Expand Up @@ -106,11 +101,7 @@ if [[ $ONLY_DOCUSAURUS == false ]]; then
# mkdir -p "website/_tutorials"
# mkdir -p "website/static/files"
if [[ $BUILD_TUTORIALS == true ]]; then
if [[ $KERNEL_NAME == false ]]; then
python3 scripts/make_tutorials.py -w "${cwd}" -e
else
python3 scripts/make_tutorials.py -w "${cwd}" -e -k "${KERNEL_NAME}"
fi
python3 scripts/make_tutorials.py -w "${cwd}" -e
else
python3 scripts/make_tutorials.py -w "${cwd}"
fi
Expand Down
13 changes: 1 addition & 12 deletions scripts/make_tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def run_script(
def gen_tutorials(
repo_dir: str,
exec_tutorials: bool,
kernel_name: Optional[str] = None,
name: Optional[str] = None,
smoke_test: bool = False,
) -> None:
Expand Down Expand Up @@ -262,26 +261,16 @@ def gen_tutorials(
default=False,
help="Execute tutorials (instead of just converting).",
)
parser.add_argument(
"-k",
"--kernel_name",
required=False,
default=None,
type=str,
help="Name of IPython / Jupyter kernel to use for executing notebooks.",
)
parser.add_argument(
"-n",
"--name",
help="Run a specific tutorial by name. The name should not include the "
".ipynb extension. If the tutorial is on the ignore list, you still need "
"to specify --include-ignored.",
".ipynb extension.",
)
args = parser.parse_args()
gen_tutorials(
args.repo_dir,
args.exec_tutorials,
args.kernel_name,
smoke_test=args.smoke,
name=args.name,
)
11 changes: 3 additions & 8 deletions scripts/publish_site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ set -e
set -x

usage() {
echo "Usage: $0 [-d] [-k KERNEL_NAME] [-v VERSION]"
echo "Usage: $0 [-d] [-v VERSION]"
echo ""
echo "Build and push updated Ax site. Will either update latest or bump stable version."
echo ""
echo " -d Use Docusaurus bot GitHub credentials. If not specified, will use default GitHub credentials."
echo " -k=KERNEL_NAME Kernel name to use for executing tutorials. Use Jupyter default if not set."
echo " -v=VERSION Build site for new library version. If not specified, will update latest."
echo ""
exit 1
}

VERSION=false
DOCUSAURUS_BOT=false
KERNEL_NAME=false

while getopts 'dhk:v:' option; do
case "${option}" in
Expand All @@ -32,9 +30,6 @@ while getopts 'dhk:v:' option; do
h)
usage
;;
k)
KERNEL_NAME=${OPTARG}
;;
v)
VERSION=${OPTARG}
;;
Expand Down Expand Up @@ -130,7 +125,7 @@ if [[ $VERSION == false ]]; then

# Build site
cd .. || exit
./scripts/make_docs.sh -b -t -k "${KERNEL_NAME}"
./scripts/make_docs.sh -b -t
rm -rf ../website/build/Ax/docs/next # don't need this

# Move built site to gh-pages (but keep old versions.js)
Expand Down Expand Up @@ -183,7 +178,7 @@ else
# Build new version of site (this will be stable, default version)
# Execute tutorials
cd .. || exit
./scripts/make_docs.sh -b -t -k "${KERNEL_NAME}"
./scripts/make_docs.sh -b -t

# Move built site to new folder (new-site) & carry over old versions
# from existing gh-pages
Expand Down

0 comments on commit 46418da

Please sign in to comment.