Reusable Tutorials Workflow #4
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: Reusable Tutorials Workflow | |
on: | |
workflow_dispatch: | |
inputs: | |
smoke_test: | |
required: true | |
type: boolean | |
use_stable_pytorch_gpytorch: | |
required: true | |
type: boolean | |
use_stable_ax: | |
required: true | |
type: boolean | |
upload_artifact: | |
required: true | |
type: boolean | |
workflow_call: | |
inputs: | |
smoke_test: | |
required: false | |
type: boolean | |
default: true | |
use_stable_pytorch_gpytorch: | |
required: false | |
type: boolean | |
default: false | |
use_stable_ax: | |
required: false | |
type: boolean | |
default: false | |
upload_artifact: | |
required: false | |
type: boolean | |
default: false | |
jobs: | |
tutorials: | |
name: Run tutorials | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: Fetch all history for all tags and branches | |
# We need to do this so setuptools_scm knows how to set the BoTorch version. | |
run: git fetch --prune --unshallow | |
- if: ${{ !inputs.use_stable_pytorch_gpytorch }} | |
name: Install latest PyTorch & GPyTorch | |
run: | | |
pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html | |
pip install git+https://github.com/cornellius-gp/linear_operator.git | |
pip install git+https://github.com/cornellius-gp/gpytorch.git | |
- if: ${{ inputs.use_stable_pytorch_gpytorch }} | |
name: Install min required PyTorch, GPyTorch, and linear_operator | |
run: | | |
python setup.py egg_info | |
req_txt="botorch.egg-info/requires.txt" | |
min_torch_version=$(grep '\btorch[>=]=' ${req_txt} | sed 's/[^0-9.]//g') | |
min_gpytorch_version=$(grep '\bgpytorch[>=]=' ${req_txt} | sed 's/[^0-9.]//g') | |
min_linear_operator_version=$(grep '\blinear_operator[>=]=' ${req_txt} | sed 's/[^0-9.]//g') | |
pip install "torch==${min_torch_version}" "gpytorch==${min_gpytorch_version}" "linear_operator==${min_linear_operator_version}" torchvision | |
- name: Install BoTorch with tutorials dependencies | |
env: | |
ALLOW_LATEST_GPYTORCH_LINOP: true | |
run: | | |
pip install .[tutorials] | |
- if: ${{ !inputs.use_stable_ax }} | |
name: Install latest Ax | |
env: | |
# This is so Ax's setup doesn't install a pinned BoTorch version. | |
ALLOW_BOTORCH_LATEST: true | |
run: | | |
pip install git+https://github.com/facebook/Ax.git | |
- if: ${{ inputs.use_stable_ax }} | |
name: Install stable Ax | |
env: | |
ALLOW_BOTORCH_LATEST: true | |
run: | | |
pip install ax-platform --no-binary ax-platform | |
- if: ${{ inputs.smoke_test }} | |
name: Run tutorials with smoke test | |
run: | | |
python scripts/run_tutorials.py -p "$(pwd)" -s | |
- if: ${{ !inputs.smoke_test }} | |
name: Run tutorials without smoke test | |
run: | | |
python scripts/run_tutorials.py -p "$(pwd)" | |
- if: ${{ inputs.upload_artifact }} | |
name: Upload performance data to artifacts branch | |
# Sometimes pushing to this branch doesn't work -- fix planned | |
continue-on-error: true | |
# 1) Switch to artifacts branch | |
# 2) Add the new CSV file | |
# 3) Get .py and .ipynb files needed for analyzing tutorials data from main | |
# 4) Run `scripts/analyze_tutorials_performance.py` to merge CSVs and | |
# update notebook | |
# 5) Commit updated notebook and new CSVs to artifacts branch | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "github-actions" | |
cp scripts/analyze_tutorials_performance.py analyze_tutorials_performance.py | |
cp notebooks/tutorials_performance_tracking.ipynb tutorials_performance_tracking.ipynb | |
git switch artifacts | |
mv *.csv tutorial_performance_data/ | |
mv tutorials_performance_tracking.ipynb notebooks/ | |
pip install seaborn | |
python analyze_tutorials_performance.py | |
git add tutorial_performance_data/*.csv notebooks/tutorials_performance_tracking.ipynb | |
git commit -a -m "Adding most recent tutorials CSVs and performance analytics notebook" | |
git push origin artifacts |