Automatically build doc notebooks (#14718)

* Test workflow

* Build doc

* Make a clean build

* Add doc config

* Restore other workflows

* Final job

* Print something in else statements

* Pull before making changes
This commit is contained in:
Sylvain Gugger 2021-12-10 14:20:56 -05:00 committed by GitHub
parent ae82ee6a48
commit 1b75d7238c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 10 deletions

View File

@ -17,11 +17,19 @@ jobs:
- uses: actions/checkout@v2
with:
repository: 'huggingface/doc-builder'
path: doc-builder
token: ${{ secrets.HUGGINGFACE_PUSH }}
- name: Clone transformers
run: |
git clone https://github.com/huggingface/transformers
- uses: actions/checkout@v2
with:
repository: 'huggingface/transformers'
path: transformers
- uses: actions/checkout@v2
with:
repository: 'huggingface/notebooks'
path: notebooks
token: ${{ secrets.HUGGINGFACE_PUSH }}
- name: Loading cache.
uses: actions/cache@v2
@ -37,7 +45,7 @@ jobs:
run: |
sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
pip install git+https://github.com/huggingface/doc-builder
pip install git+https://github.com/huggingface/doc-builder@add-install-cell
pip install git+https://github.com/huggingface/transformers#egg=transformers[dev]
export TORCH_VERSION=$(python -c "from torch import version; print(version.__version__.split('+')[0])")
@ -55,15 +63,37 @@ jobs:
run: |
git config --global user.name "Hugging Face"
git config --global user.email transformers@huggingface.co
cd doc-builder
git pull origin main
cd ..
cd notebooks
git pull origin master
cd ..
- name: Make documentation
run: |
doc-builder build transformers ./transformers/docs/source
doc-builder build transformers transformers/docs/source --build_dir doc-builder/build --notebook_dir notebooks/transformers_doc --clean
- name: Push to repository
- name: Push to repositories
run: |
git add build
git commit -m "Updated with commit ${{ github.sha }}"
git push origin main
cd doc-builder
if [[ `git status --porcelain` ]]; then
git add build
git commit -m "Updated with commit ${{ github.sha }}"
git push origin main
else
echo "No diff in the documentation."
fi
cd ..
cd notebooks
if [[ `git status --porcelain` ]]; then
git add build
git commit -m "Updated Transformer doc notebooks with commit ${{ github.sha }}"
git push origin master
else
echo "No diff in the notebooks."
fi
cd ..

7
docs/source/_config.py Normal file
View File

@ -0,0 +1,7 @@
INSTALL_CONTENT = """
# Transformers installation ! pip install transformers datasets # To install from source instead of the last release,
comment the command above and uncomment the following one. # ! pip install
git+https://github.com/huggingface/transformers.git
"""
notebook_first_cells = [{"type": "code", "content": INSTALL_CONTENT}]