build(deps): bump docker/metadata-action from 115662203e5f4c9b240a57397f721baaab82a488 to 359e915ab3220d88514ed693793a5cc795192aa6 in the github-actions group #2897
Workflow file for this run
This file contains 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
name: demo | |
on: | |
# Run 'test-demo' on every pull request to the main branch | |
pull_request: | |
branches: [main] | |
# Run 'test-demo' on every push to the main branch or both jobs when a new version tag is pushed | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
# Run 'sync-to-hub' on a scheduled cron job | |
schedule: | |
- cron: '0 2 10 * *' # At 02:00 on day-of-month 10 (every month) | |
# Allow manual triggering of the workflow | |
workflow_dispatch: | |
jobs: | |
test-demo: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
python: ["3.10"] | |
framework: [tensorflow, pytorch] | |
steps: | |
- if: matrix.os == 'macos-latest' | |
name: Install MacOS prerequisites | |
run: brew install cairo pango gdk-pixbuf libffi | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
architecture: x64 | |
- if: matrix.framework == 'tensorflow' | |
name: Cache python modules (TF) | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('demo/tf-requirements.txt') }} | |
- if: matrix.framework == 'pytorch' | |
name: Cache python modules (PT) | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('demo/pt-requirements.txt') }} | |
- if: matrix.framework == 'tensorflow' | |
name: Install dependencies (TF) | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e .[tf,viz,html] --upgrade | |
pip install -r demo/tf-requirements.txt | |
- if: matrix.framework == 'pytorch' | |
name: Install dependencies (PT) | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e .[torch,viz,html] --upgrade | |
pip install -r demo/pt-requirements.txt | |
- if: matrix.framework == 'tensorflow' | |
name: Run demo (TF) | |
env: | |
USE_TF: 1 | |
run: | | |
streamlit --version | |
screen -dm streamlit run demo/app.py | |
sleep 10 | |
curl http://localhost:8501/docs | |
- if: matrix.framework == 'pytorch' | |
name: Run demo (PT) | |
env: | |
USE_TORCH: 1 | |
run: | | |
streamlit --version | |
screen -dm streamlit run demo/app.py | |
sleep 10 | |
curl http://localhost:8501/docs | |
# This job only runs when a new version tag is pushed or during the cron job or when manually triggered | |
sync-to-hub: | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
needs: test-demo | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
python: ["3.10"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
architecture: x64 | |
- name: Install huggingface_hub | |
run: pip install huggingface-hub | |
- name: Upload folder to Hugging Face | |
# Only keep the requirements.txt file for the demo (PyTorch) | |
run: | | |
mv demo/pt-requirements.txt demo/requirements.txt | |
rm demo/tf-requirements.txt | |
python -c " | |
from huggingface_hub import HfApi | |
api = HfApi(token='${{ secrets.HF_TOKEN }}') | |
repo_id = 'mindee/doctr' | |
api.upload_folder(repo_id=repo_id, repo_type='space', folder_path='demo/') | |
api.restart_space(repo_id=repo_id, factory_reboot=True) | |
" |