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:
48
.github/workflows/build_documentation.yml
vendored
48
.github/workflows/build_documentation.yml
vendored
@@ -17,11 +17,19 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
repository: 'huggingface/doc-builder'
|
repository: 'huggingface/doc-builder'
|
||||||
|
path: doc-builder
|
||||||
token: ${{ secrets.HUGGINGFACE_PUSH }}
|
token: ${{ secrets.HUGGINGFACE_PUSH }}
|
||||||
|
|
||||||
- name: Clone transformers
|
- uses: actions/checkout@v2
|
||||||
run: |
|
with:
|
||||||
git clone https://github.com/huggingface/transformers
|
repository: 'huggingface/transformers'
|
||||||
|
path: transformers
|
||||||
|
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
repository: 'huggingface/notebooks'
|
||||||
|
path: notebooks
|
||||||
|
token: ${{ secrets.HUGGINGFACE_PUSH }}
|
||||||
|
|
||||||
- name: Loading cache.
|
- name: Loading cache.
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
@@ -37,7 +45,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
|
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]
|
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])")
|
export TORCH_VERSION=$(python -c "from torch import version; print(version.__version__.split('+')[0])")
|
||||||
@@ -55,15 +63,37 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git config --global user.name "Hugging Face"
|
git config --global user.name "Hugging Face"
|
||||||
git config --global user.email transformers@huggingface.co
|
git config --global user.email transformers@huggingface.co
|
||||||
|
|
||||||
|
cd doc-builder
|
||||||
git pull origin main
|
git pull origin main
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
cd notebooks
|
||||||
|
git pull origin master
|
||||||
|
cd ..
|
||||||
|
|
||||||
- name: Make documentation
|
- name: Make documentation
|
||||||
run: |
|
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: |
|
run: |
|
||||||
git add build
|
cd doc-builder
|
||||||
git commit -m "Updated with commit ${{ github.sha }}"
|
if [[ `git status --porcelain` ]]; then
|
||||||
git push origin main
|
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
7
docs/source/_config.py
Normal 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}]
|
||||||
Reference in New Issue
Block a user