-
Notifications
You must be signed in to change notification settings - Fork 17
Add Sphinx gallery and fixes to the doc build #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
14f786d
Add Sphinx gallery and basic API docs
svekars 169777a
Fix lintrunner
svekars 6be2d56
Update
svekars e739206
Update
svekars e9a15ac
Update
svekars 137f38e
Add preview
svekars 80a3303
Update
svekars 89ef2ca
Update
svekars c67a3a8
Update
svekars 85bb7a7
Update
svekars 5b48300
Update
svekars eb4d386
Update
svekars File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ on: | |
jobs: | ||
build-docs: | ||
name: Build Documentation | ||
runs-on: ubuntu-latest | ||
runs-on: linux.g5.4xlarge.nvidia.gpu | ||
timeout-minutes: 30 | ||
steps: | ||
- name: Checkout | ||
|
@@ -24,7 +24,7 @@ jobs: | |
miniconda-version: "latest" | ||
activate-environment: test | ||
python-version: '3.10' | ||
auto-activate-base: false | ||
auto-activate: false | ||
- name: Verify conda environment | ||
shell: bash -l {0} | ||
run: | | ||
|
@@ -36,7 +36,7 @@ jobs: | |
run: python -m pip install --upgrade pip | ||
- name: Install pytorch | ||
shell: bash -l {0} | ||
run: python -m pip install torch==2.9.0.dev20250826 --extra-index-url https://download.pytorch.org/whl/nightly/cpu | ||
run: python -m pip install torch==2.9.0 --index-url https://download.pytorch.org/whl/test/cu130 | ||
- name: Install monarch | ||
shell: bash -l {0} | ||
run: python -m pip install monarch-no-torch==0.1.0.dev20250826 --find-links assets/ci | ||
|
@@ -51,61 +51,90 @@ jobs: | |
- name: Build docs | ||
shell: bash -l {0} | ||
working-directory: docs | ||
run: make html --keep-going SPHINXOPTS='-W' | ||
run: | | ||
set +e # Don't exit on error | ||
make html SPHINXOPTS="-WT --keep-going" || echo "Build completed with warnings/errors" | ||
set -e # Re-enable exit on error for subsequent commands | ||
- name: Upload docs artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: docs | ||
path: docs/build/html/ | ||
|
||
# doc-preview: | ||
# runs-on: [ubuntu-latest] | ||
# needs: build-docs | ||
# if: ${{ github.event_name == 'pull_request' }} | ||
# steps: | ||
# - name: Checkout | ||
# uses: actions/checkout@v4 | ||
# - name: Download artifact | ||
# uses: actions/download-artifact@v4 | ||
# with: | ||
# name: docs | ||
# path: docs | ||
# - name: Add noindex to preview docs | ||
# run: | | ||
# echo "Adding noindex meta tag to prevent search engine indexing of preview docs" | ||
# find docs -name "*.html" -print0 | xargs -0 sed -i 's/<head>/<head>\n <meta name="robots" content="noindex">/' | ||
# - name: Upload docs preview | ||
# uses: seemethere/upload-artifact-s3@v5 | ||
# if: ${{ github.event_name == 'pull_request' }} | ||
# with: | ||
# retention-days: 14 | ||
# s3-bucket: doc-previews | ||
# if-no-files-found: error | ||
# path: docs | ||
# s3-prefix: meta-pytorch/forge/${{ github.event.pull_request.number }} | ||
doc-preview: | ||
runs-on: linux.large | ||
needs: build-docs | ||
if: ${{ github.event_name == 'pull_request' }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: docs | ||
path: docs | ||
- name: Add noindex to preview docs | ||
run: | | ||
echo "Adding noindex meta tag to prevent search engine indexing of preview docs" | ||
find docs -name "*.html" -print0 | xargs -0 sed -i 's/<head>/<head>\n <meta name="robots" content="noindex">/' | ||
- name: Upload docs preview | ||
uses: seemethere/upload-artifact-s3@v5 | ||
if: ${{ github.event_name == 'pull_request' }} | ||
with: | ||
retention-days: 14 | ||
s3-bucket: doc-previews | ||
if-no-files-found: error | ||
path: docs | ||
s3-prefix: meta-pytorch/forge/${{ github.event.pull_request.number }} | ||
|
||
upload: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# Grant write permission here so that the doc can be pushed to gh-pages branch | ||
contents: write | ||
needs: build-docs | ||
if: github.repository == 'meta-pytorch/forge' && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch') | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: gh-pages | ||
persist-credentials: true | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: docs | ||
path: docs | ||
#- name: Add no-index tag | ||
# run: | | ||
# REF_NAME=$(echo "${{ github.ref }}") | ||
# echo "Ref name: ${REF_NAME}" | ||
# if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then | ||
# find docs -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">'; | ||
# fi | ||
- name: Move and commit changes | ||
run: | | ||
set -euo pipefail | ||
# Get github.ref for the output doc folder. By default "main" | ||
# If matches a tag like refs/tags/v1.12.0-rc3 or | ||
# refs/tags/v1.12.0 convert to 1.12 | ||
GITHUB_REF=${{ github.ref }} | ||
|
||
deploy-docs: | ||
needs: build-docs | ||
if: github.ref == 'refs/heads/main' | ||
permissions: | ||
pages: write | ||
id-token: write | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download build artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: docs | ||
path: . | ||
# Convert refs/tags/v1.12.0rc3 into 1.12. | ||
# Adopted from https://github.com/pytorch/pytorch/blob/main/.github/workflows/_docs.yml#L150C11-L155C13 | ||
if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+\.[0-9]+)\.* ]]; then | ||
TARGET_FOLDER="${BASH_REMATCH[1]}" | ||
else | ||
TARGET_FOLDER="main" | ||
fi | ||
echo "Target Folder: ${TARGET_FOLDER}" | ||
|
||
- name: Upload Pages artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: . | ||
mkdir -p "${TARGET_FOLDER}" | ||
rm -rf "${TARGET_FOLDER}"/* | ||
mv docs/* "${TARGET_FOLDER}" | ||
|
||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 | ||
git config user.name 'pytorchbot' | ||
git config user.email '[email protected]' | ||
git add "${TARGET_FOLDER}" || true | ||
git commit -m "auto-generating sphinx docs" || true | ||
git push -f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
sphinx==7.2.6 | ||
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git@pytorch_sphinx_theme2#egg=pytorch_sphinx_theme2 | ||
pytorch-sphinx-theme2==0.1.0 | ||
docutils>=0.18.1,<0.21 | ||
sphinx-design==0.6.1 | ||
sphinxcontrib-mermaid==1.0.0 | ||
sphinx-gallery==0.19.0 | ||
myst-parser #==0.18.1 # if want to contribute in markdown | ||
sphinx-sitemap==2.7.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Tutorials | ||
========= | ||
|
||
This gallery contains tutorials and examples to help you get started with Forge. | ||
Each tutorial demonstrates specific features and use cases with practical examples. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for my understanding, once we have wheels that work in CI then we can go ahead and remove all of this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be problematic for a local installation that doesn't have all these deps more than the CI since we are installing all this. Also, just for API docs these import might not be necessarily needed. Since I'm only adding doc build changes and sphinx gallery in this PR, I will delete this part for now.