Hello,
I’m trying to commit to GitHub but I keep getting an error during deployment because a conda package isn’t installed.
What is the correct way to commit my package if it requires a conda package to be installed?
Hello,
I’m trying to commit to GitHub but I keep getting an error during deployment because a conda package isn’t installed.
What is the correct way to commit my package if it requires a conda package to be installed?
You need to set your requirements in settings.ini. For an example look at this:
Hi !
I have been using nbdev 1 very successfully for over a year, but when migrating to nbdev 2 I ran into the same issue: the packages I put in conda_requirements seem not to be installed for the github actions, whereas before this happened without any problems. I use
conda_requirements = pandas python-graphviz matplotlib pillow pytorch
pip_requirements = gtsam>=4.2a8 plotly requests
but the action fails as pillow is not installed.
I know pillow can be installed via pip, but python-graphviz
must go via conda.
Tracking now with issue here: Website is broken · Issue #4 · gtbook/gtbook · GitHub
Anyone? Is this not a bug?
Hi All ! I am still wondering how I can have conda requirements? That was definitely a thing in nbdev 1, but somehow seems to be broken in nbdev2. Can anyone help?
You set them in your settings.ini
file.
Thanks, Mat. I probably explained poorly: the github actions defined in nbdev2 no longer seem to “honor” those conda_requirements. After a lot of iterations, I managed to get around it with a custom workflow that sets up the conda environment I need (and does test and deploy in one fell swoop):
name: Deploy to GitHub Pages
permissions:
contents: write
pages: write
on:
push:
branches: [ "main", "master" ]
workflow_dispatch:
jobs:
test_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Activate conda env with environment.yml
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: false
auto-activate-base: false
activate-environment: gtbook
python-version: 3.9
environment-file: environment.yml
- name: Install nbdev
shell: bash -l {0}
run: |
pip install -U nbdev
- name: Doing editable install
shell: bash -l {0}
run: |
test -f setup.py && pip install -e ".[dev]"
- name: Check we are starting with clean git checkout
shell: bash -l {0}
run: |
if [[ `git status --porcelain -uno` ]]; then
git diff
echo "git status is not clean"
false
fi
- name: Trying to strip out notebooks
shell: bash -l {0}
run: |
nbdev_clean
git status -s # display the status to see which nbs need cleaning up
if [[ `git status --porcelain -uno` ]]; then
git status -uno
echo -e "!!! Detected unstripped out notebooks\n!!!Remember to run nbdev_install_hooks"
echo -e "This error can also happen if you are using an older version of nbdev relative to what is in CI. Please try to upgrade nbdev with the command `pip install -U nbdev`"
false
fi
- name: Run nbdev_export
shell: bash -l {0}
run: |
nbdev_export
if [[ `git status --porcelain -uno` ]]; then
echo "::error::Notebooks and library are not in sync. Please run nbdev_export."
git status -uno
git diff
exit 1;
fi
- name: Run nbdev_test
shell: bash -l {0}
run: |
nbdev_test
- name: Run nbdev_docs
shell: bash -l {0}
run: |
nbdev_docs
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ github.token }}
force_orphan: true
publish_dir: ./_docs
# The following lines assign commit authorship to the official GH-Actions bot for deploys to `gh-pages` branch.
# You can swap them out with your own user credentials.
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com
Thank you for this script, Frank. Also have some packages that require conda and was tearing my hair out trying to find a workaround. Have directly incorporated your script into my package
Only change I made was to use micromamba
with caching instead of miniconda
, yielding a ~5X speed up in CI time
- name: Activate conda env with environment.yml
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: '1.3.1-0'
environment-file: environment.yml
init-shell: >-
bash
powershell
cache-environment: true
post-cleanup: 'all'