Search code examples
condagitpod

How to efficiently set up development conda env in Gitpod?


I would like create a Gitpod workspace for a GitHub project of ours so that we (4 ppl) can develop in the cloud. Our project is a conda package and locally we develop it in a dedicated development environment, having a recipe for it in a environment.yml. Additionally, in order to speed up the solver we use mamba on top of Miniconda.

I am not sure how to properly set up the instructions in .gitpod.yml. I thought the way I have it now was right, yet when I closed and then opened the editor after a few hours only command part was executed with a message conda command not found...

tasks:

    - name: Mambaforge + dev.env setup
  
      init: |
        wget -O Mambaforge.sh  "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh"
        bash Mambaforge.sh -b -p "${HOME}/conda" && rm -f Mambaforge.sh
        source "${HOME}/conda/etc/profile.d/conda.sh"
        source "${HOME}/conda/etc/profile.d/mamba.sh"
        mamba env create -f environment.yml
  
      command: |
        conda activate dev
        echo "<peon voice> Ready to work!"
  1. How should I adjust the instruction so that it does not break?
  2. Maybe I should put some lines in a before section?
  3. Could I maybe improve this setup with prebuilds?

References:


Solution

  • The easiest and cleanest solution is to use a Mambaforge base docker image, can be specified in YAML too:

    image: condaforge/mambaforge:22.9.0-1
    

    That way before section is not requried, the package manager is already initialised and the development environment in init can be marked as prebuild, indeed.