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:…


This content originally appeared on DEV Community and was authored by Matt Eland

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

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"
    }
}

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.


This content originally appeared on DEV Community and was authored by Matt Eland


Print Share Comment Cite Upload Translate Updates
APA

Matt Eland | Sciencx (2024-09-13T03:22:15+00:00) Recommended Codespace Configuration for Polyglot Notebooks. Retrieved from https://www.scien.cx/2024/09/13/recommended-codespace-configuration-for-polyglot-notebooks/

MLA
" » Recommended Codespace Configuration for Polyglot Notebooks." Matt Eland | Sciencx - Friday September 13, 2024, https://www.scien.cx/2024/09/13/recommended-codespace-configuration-for-polyglot-notebooks/
HARVARD
Matt Eland | Sciencx Friday September 13, 2024 » Recommended Codespace Configuration for Polyglot Notebooks., viewed ,<https://www.scien.cx/2024/09/13/recommended-codespace-configuration-for-polyglot-notebooks/>
VANCOUVER
Matt Eland | Sciencx - » Recommended Codespace Configuration for Polyglot Notebooks. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/13/recommended-codespace-configuration-for-polyglot-notebooks/
CHICAGO
" » Recommended Codespace Configuration for Polyglot Notebooks." Matt Eland | Sciencx - Accessed . https://www.scien.cx/2024/09/13/recommended-codespace-configuration-for-polyglot-notebooks/
IEEE
" » Recommended Codespace Configuration for Polyglot Notebooks." Matt Eland | Sciencx [Online]. Available: https://www.scien.cx/2024/09/13/recommended-codespace-configuration-for-polyglot-notebooks/. [Accessed: ]
rf:citation
» Recommended Codespace Configuration for Polyglot Notebooks | Matt Eland | Sciencx | https://www.scien.cx/2024/09/13/recommended-codespace-configuration-for-polyglot-notebooks/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.