Recommended Codespace Configuration for Polyglot Notebooks

In order to get Polyglot Notebooks to work with GitHub Codespaces, you’ll need to match the current requirements of the Polyglot Notebooks extension and its underlying .NET Interactive kernels.

This relies on two files in your .devcontainer directory:

  • Dockerfile which describes the Docker container the Codespace will run in
  • devcontainer.json which describes how the dev container is configured in terms of extensions and ports

Current Requirements

As of September of 2024, Polyglot Notebooks requires the .NET 8 SDK.

Therefore, I recommend the following settings as basic starter templates:

Dockerfile

In the dockerfile, it’s important to use the .NET image that Polyglot Notebooks currently requires. At the moment, this is .NET 8.

ARG VARIANT="8.0"
FROM mcr.microsoft.com/devcontainers/dotnet:${VARIANT} ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
Enter fullscreen mode
Exit fullscreen mode

devcontainer.json

The devcontainer.json file is a bit more flexible, but the critical thing we need to do is specify that the VS Code extension ms-dotnettools.dotnet-interactive-vscode should be installed. This is the Polyglot Notebooks extension.

{ "name": "ASPNET", // Configure tool-specific properties. "build": { "dockerfile": "Dockerfile", "args": { "VARIANT": "8.0", "NODE_VERSION": "16" } }, "customizations": { // Configure properties specific to VS Code. "vscode": { "extensions": [ "GitHub.github-vscode-theme", // Optional. Codespace IDE theming. "ms-dotnettools.csharp", // Optional. Helpful for C# development "ms-dotnettools.dotnet-interactive-vscode" // Polyglot Notebooks. Required ] } }, // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. // "postCreateCommand": "gcc -v", "onCreateCommand": "echo PS1='\"$ \"' >> ~/.bashrc && dotnet dev-certs https", //Set Terminal Prompt to $ // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. "remoteUser": "vscode", "features": { "powershell": "latest" }
}
Enter fullscreen mode
Exit fullscreen mode

While these settings are initially picked based on those in my book, Data Science in .NET with Polyglot Notebooks, this is intended to be a living document that can be updated as Polyglot Notebooks moves to future versions of .NET or the recommended configuration settings change.

If you have any suggestions or corrections to make to either the Dockerfile or the devcontainer.json file, please get in touch with me.


Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Flutter app development.