Remote development environments are all the rage, but starting from scratch is difficult. This is a quick post to get you off the ground by comparing GitHub Codespaces and GitLab/GitPod Workspaces.
Dear Visitor,
Thanks for reading my blog. Code quality in data science is one of those topics that everyone is passionate about, but no one knows how to start with. If you want to improve, you are in the best place. Subscribe to get notified of new content or join our discord at https://cq4ds.com/
Codespaces
You can start a Codespace by going into a repository and clicking Code->Codespaces->Create.
You will need a "devcontainer.json" in that repository's ".devcontainer" directory. The content is just a plain JSON, as you can see below:
{
"name": "Ubuntu",
"hostRequirements": {
"cpus": 4
},
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers/features/python:1": {}
},
"customizations": {
"codespaces": {
"openFiles": [
"README.md"
]
},
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.black-formatter",
"ms-vsliveshare.vsliveshare"
]
}
},
"remoteEnv": {
"JUPYTER_CONFIG_DIR": "."
},
"updateContentCommand": "bash .devcontainer/setup.sh"
}
Number of CPUs for the codespace (4)
Instructions for the container image (Ubuntu with Python)
Customisations, for example, which VSCode extensions will be installed in the remote environment (python relevant extensions)
Environment variables that will be set on the new machine
A startup shell command where you can do custom instructions (download a different version of Python with pyenv, create a virtual environment, or anything else; more on this in the next post)
Workspaces
You can start a Workspace by going into a repository on Gitlab and clicking Edit->Gitpod.
You will need a ".gitpod.yml" in that repository's root directory. The content is just a plain YAML, as you can see below:
tasks:
- name: Setup
init: bash ./.devcontainer/setup.sh
vscode:
extensions:
- ms-python.python
- ms-python.black-formatter
- genuitecllc.codetogether
ports:
- port: 8889
onOpen: open-preview
visibility: public
- port: 8000
onOpen: open-preview
visibility: public
Instructions for the container (This example uses the default, called "Workspace-Full")
A shell script to run at startup (same as with codespaces)
VSCode extensions (same as with codespaces. The only difference is that you can only use open-source extensions as Gitpod uses a different source than Github (which is MicroSoft).
And some ports to be open at startup if you need to run, for example, a notebook server or test a local FastAPI deployment.
And that's it...
As you can see, both of them refer to a ".devcontainer/setup.sh". More on this in the next post. You can ask why the gitpod one refers to the ".devcontainer" directory, and that's because these examples are from our training program, where we maintain the two versions in a single project. Get in touch if you would like to know more about that.
I hope you find this helpful and give it a try. Both places have generous free compute for experimentation.
Next: GitHub Actions vs Gitlab Pipelines.