Skip to content

Instantly share code, notes, and snippets.

@mhucka
Created December 26, 2025 05:46
Show Gist options
  • Select an option

  • Save mhucka/dc3e59c48334fb98f56aac08b47eb37b to your computer and use it in GitHub Desktop.

Select an option

Save mhucka/dc3e59c48334fb98f56aac08b47eb37b to your computer and use it in GitHub Desktop.
Script to test a notebook using papermill
#!/bin/bash
py_version="${1}"
notebook_file="${2}"
export PIP_INDEX_URL="https://test.pypi.org/simple/"
export PIP_EXTRA_INDEX_URL="https://pypi.org/simple/"
echo "~~~~ Testing ${notebook_file}"
eval "$(pyenv init -)"
# Deactivate any pyenv we might be inside right now.
pyenv deactivate >& /dev/null || true
# Ensure we have the requested version of Python.
pyenv install -s "${py_version}"
# (Re)create a pyenv virtual env.
pyenv virtualenv-delete -f tfq-test-venv || true
pyenv virtualenv -v "${py_version}" tfq-test-venv
pyenv activate tfq-test-venv
pip install --upgrade pip
pip install papermill ipykernel
papermill "${notebook_file}" "${notebook_file}.output.ipynb"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment