-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github action tests for Nano How-To Guides: Inference > PyTorch
- Loading branch information
1 parent
5f09fd3
commit 2e73ead
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Nano Unit Tests for How-To Guides Notebooks | ||
|
||
on: | ||
# Triggers the workflow on push or pull request events but only for the main branch | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
paths: | ||
#- 'python/nano/**' | ||
- '.github/workflows/nano_howto_guides_tests.yml' | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
nano-howto-guides-inference-test: | ||
# The type of runner that the job will run on | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ["ubuntu-20.04"] | ||
python-version: ["3.7"] | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade setuptools==58.0.4 | ||
python -m pip install --upgrade wheel | ||
- name: Run unit tests for Inference PyTorch how-to guides | ||
shell: bash | ||
run: | | ||
$CONDA/bin/conda create -n howto-guides-inference-pytorch -y python==3.7.10 setuptools=58.0.4 | ||
source $CONDA/bin/activate howto-guides-inference-pytorch | ||
$CONDA/bin/conda info | ||
bash python/nano/dev/build_and_install.sh linux default false pytorch | ||
source bigdl-nano-init | ||
bash python/nano/tutorial/notebook/inference/pytorch/run-nano-howto-guides-inference-pytorch-tests.sh | ||
source $CONDA/bin/deactivate | ||
$CONDA/bin/conda remove -n howto-guides-inference-pytorch --all | ||
env: | ||
ANALYTICS_ZOO_ROOT: ${{ github.workspace }} |
24 changes: 24 additions & 0 deletions
24
...nano/tutorial/notebook/inference/pytorch/run-nano-howto-guides-inference-pytorch-tests.sh
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# export ANALYTICS_ZOO_ROOT=${ANALYTICS_ZOO_ROOT} | ||
# export NANO_HOME=${ANALYTICS_ZOO_ROOT}/python/nano/src | ||
export NANO_HOWTO_GUIDES_TEST_DIR=${ANALYTICS_ZOO_ROOT}/python/nano/tutorial/notebook/inference/pytorch | ||
|
||
set -e | ||
|
||
# the number of batches to run is limited for testing purposes | ||
sed -i 's/Trainer(max_epochs=1)/Trainer(max_epochs=1, fast_dev_run=True)/' $NANO_HOWTO_GUIDES_TEST_DIR/quantize_pytorch_inference_inc.ipynb $NANO_HOWTO_GUIDES_TEST_DIR/quantize_pytorch_inference_pot.ipynb | ||
|
||
# comment out the install command for bigdl-nano[pytorch] | ||
sed -i 's/!pip install --pre --upgrade bigdl-nano\[pytorch]/#!pip install --pre --upgrade bigdl-nano[pytorch]/' $NANO_HOWTO_GUIDES_TEST_DIR/* | ||
|
||
echo "Start testing" | ||
start=$(date "+%s") | ||
|
||
python -m pytest -s --nbmake --nbmake-timeout=600 --nbmake-kernel=python3 ${NANO_HOWTO_GUIDES_TEST_DIR} | ||
|
||
now=$(date "+%s") | ||
time=$((now-start)) | ||
|
||
echo "BigDL-Nano how-to guides tests finished." | ||
echo "Time used: $time seconds" |