Skip to content

MNT Add initial setup for devcontainer #31096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

lesteve
Copy link
Member

@lesteve lesteve commented Mar 28, 2025

Instructions how to try it out are in #31091.

I guess let's try to keep feed-back about the user experience in #31091.

Copy link

github-actions bot commented Mar 28, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: ff82f55. Link to the linter CI: here

@betatim
Copy link
Member

betatim commented Apr 1, 2025

Want to make it "not a draft" so we can merge this?

@lesteve lesteve marked this pull request as ready for review April 1, 2025 10:09
@lesteve
Copy link
Member Author

lesteve commented Apr 1, 2025

Want to make it "not a draft" so we can merge this?

Done 😉. I was planning to add some minimal doc somewhere, but this can be done in a further PR.

@ogrisel
Copy link
Member

ogrisel commented Apr 7, 2025

Maybe we should add some minimal doc first to avoid confusing people.

For instance, when opening VS Code on macOS on a latptop with an arm64/M1 processor with the scikit-learn source folder checked out on this branch, VS Code asked me if I wanted to reopen the project within the dev container but then it fails with the following log:

[2025-04-07T09:52:24.373Z] Dev Containers 0.401.0 in VS Code 1.98.2 (ddc367ed5c8936efe395cffeec279b04ffd7db78).
[2025-04-07T09:52:24.373Z] Start: Resolving Remote
[2025-04-07T09:52:24.383Z] Setting up container for folder or workspace: /Users/ogrisel/code/scikit-learn
[2025-04-07T09:52:24.383Z] Context: desktop-linux
[2025-04-07T09:52:24.395Z] Start: Check Docker is running
[2025-04-07T09:52:24.395Z] Start: Run: docker version
[2025-04-07T09:52:24.419Z] Client:
 Version:           28.0.1
 API version:       1.48
 Go version:        go1.23.6
 Git commit:        068a01e
 Built:             Wed Feb 26 10:38:16 2025
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

[2025-04-07T09:52:24.420Z] Server: Docker Desktop 4.39.0 (184744)
 Engine:
  Version:          28.0.1
  API version:      1.48 (minimum version 1.24)
  Go version:       go1.23.6
  Git commit:       bbd0a17
  Built:            Wed Feb 26 10:40:57 2025
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.7.25
  GitCommit:        bcc810d6b9066471b0b6fa75f557a15a1cbf31bb
 runc:
  Version:          1.2.4
  GitCommit:        v1.2.4-0-g6c52b3f
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
[2025-04-07T09:52:24.422Z] Stop (27 ms): Run: docker version
[2025-04-07T09:52:24.423Z] Stop (28 ms): Check Docker is running
[2025-04-07T09:52:24.423Z] Start: Run: docker volume ls -q
[2025-04-07T09:52:24.440Z] Stop (17 ms): Run: docker volume ls -q
[2025-04-07T09:52:24.440Z] Start: Run: docker ps -q -a --filter label=vsch.local.folder=/Users/ogrisel/code/scikit-learn --filter label=vsch.quality=stable
[2025-04-07T09:52:24.456Z] Stop (16 ms): Run: docker ps -q -a --filter label=vsch.local.folder=/Users/ogrisel/code/scikit-learn --filter label=vsch.quality=stable
[2025-04-07T09:52:24.456Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/Users/ogrisel/code/scikit-learn --filter label=devcontainer.config_file=/Users/ogrisel/code/scikit-learn/.devcontainer/devcontainer.json
[2025-04-07T09:52:24.474Z] Stop (18 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=/Users/ogrisel/code/scikit-learn --filter label=devcontainer.config_file=/Users/ogrisel/code/scikit-learn/.devcontainer/devcontainer.json
[2025-04-07T09:52:24.474Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/Users/ogrisel/code/scikit-learn
[2025-04-07T09:52:24.491Z] Stop (17 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=/Users/ogrisel/code/scikit-learn
[2025-04-07T09:52:24.491Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/Users/ogrisel/code/scikit-learn
[2025-04-07T09:52:24.505Z] Stop (14 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=/Users/ogrisel/code/scikit-learn
[2025-04-07T09:52:24.505Z] Running Dev Containers CLI:   up --user-data-folder /Users/ogrisel/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --container-session-data-folder /tmp/devcontainers-736b008d-3df6-4ed2-857d-ebf2e221425b1744019543794 --workspace-folder /Users/ogrisel/code/scikit-learn --workspace-mount-consistency cached --gpu-availability detect --id-label devcontainer.local_folder=/Users/ogrisel/code/scikit-learn --id-label devcontainer.config_file=/Users/ogrisel/code/scikit-learn/.devcontainer/devcontainer.json --log-level debug --log-format json --config /Users/ogrisel/code/scikit-learn/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root --include-configuration --include-merged-configuration
[2025-04-07T09:52:24.530Z] ProxyResolver#loadSystemCertificates count
[2025-04-07T09:52:24.538Z] ProxyResolver#loadSystemCertificates count filtered
[2025-04-07T09:52:24.538Z] Start: Run: /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Users/ogrisel/.vscode/extensions/ms-vscode-remote.remote-containers-0.401.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /Users/ogrisel/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --container-session-data-folder /tmp/devcontainers-736b008d-3df6-4ed2-857d-ebf2e221425b1744019543794 --workspace-folder /Users/ogrisel/code/scikit-learn --workspace-mount-consistency cached --gpu-availability detect --id-label devcontainer.local_folder=/Users/ogrisel/code/scikit-learn --id-label devcontainer.config_file=/Users/ogrisel/code/scikit-learn/.devcontainer/devcontainer.json --log-level debug --log-format json --config /Users/ogrisel/code/scikit-learn/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root --include-configuration --include-merged-configuration
[2025-04-07T09:52:24.683Z] @devcontainers/cli 0.74.0. Node.js v20.18.2. darwin 24.2.0 arm64.
[2025-04-07T09:52:24.683Z] Start: Run: docker buildx version
[2025-04-07T09:52:24.737Z] Stop (54 ms): Run: docker buildx version
[2025-04-07T09:52:24.738Z] github.com/docker/buildx v0.21.1-desktop.2 65a04767fd3000fbac3b7120cc6115d518678e33
[2025-04-07T09:52:24.738Z] 
[2025-04-07T09:52:24.738Z] Start: Run: docker -v
[2025-04-07T09:52:24.749Z] Stop (11 ms): Run: docker -v
[2025-04-07T09:52:24.749Z] Start: Resolving Remote
[2025-04-07T09:52:24.751Z] Start: Run: git rev-parse --show-cdup
[2025-04-07T09:52:24.762Z] Stop (11 ms): Run: git rev-parse --show-cdup
[2025-04-07T09:52:24.763Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/Users/ogrisel/code/scikit-learn --filter label=devcontainer.config_file=/Users/ogrisel/code/scikit-learn/.devcontainer/devcontainer.json
[2025-04-07T09:52:24.782Z] Stop (19 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=/Users/ogrisel/code/scikit-learn --filter label=devcontainer.config_file=/Users/ogrisel/code/scikit-learn/.devcontainer/devcontainer.json
[2025-04-07T09:52:24.782Z] Start: Run: docker inspect --type image mcr.microsoft.com/devcontainers/universal:2
[2025-04-07T09:52:24.799Z] Stop (17 ms): Run: docker inspect --type image mcr.microsoft.com/devcontainers/universal:2
[2025-04-07T09:52:24.800Z] Loading 40 extra certificates from /var/folders/_y/lfnx34p13w3_sr2k12bjb05w0000gn/T/vsch/certificates-d83a8480b394e47ecb8e4412305838f4701c4ac72f86d49f2957b06585b2160c.pem.
[2025-04-07T09:52:25.182Z] Error fetching image details: No manifest found for mcr.microsoft.com/devcontainers/universal:2.
[2025-04-07T09:52:25.183Z] Start: Run: docker pull mcr.microsoft.com/devcontainers/universal:2
[2025-04-07T09:52:25.808Z] 2: Pulling from devcontainers/universal
[2025-04-07T09:52:25.906Z] no matching manifest for linux/arm64/v8 in the manifest list entries
[2025-04-07T09:52:25.907Z] Stop (724 ms): Run: docker pull mcr.microsoft.com/devcontainers/universal:2
[2025-04-07T09:52:25.907Z] []
[2025-04-07T09:52:25.907Z] Error response from daemon: No such image: mcr.microsoft.com/devcontainers/universal:2

[2025-04-07T09:52:25.907Z] Error: Command failed: docker inspect --type image mcr.microsoft.com/devcontainers/universal:2
[2025-04-07T09:52:25.907Z]     at ytA (/Users/ogrisel/.vscode/extensions/ms-vscode-remote.remote-containers-0.401.0/dist/spec-node/devContainersSpecCLI.js:468:1260)
[2025-04-07T09:52:25.907Z]     at bH (/Users/ogrisel/.vscode/extensions/ms-vscode-remote.remote-containers-0.401.0/dist/spec-node/devContainersSpecCLI.js:468:1002)
[2025-04-07T09:52:25.907Z]     at async TtA (/Users/ogrisel/.vscode/extensions/ms-vscode-remote.remote-containers-0.401.0/dist/spec-node/devContainersSpecCLI.js:485:3848)
[2025-04-07T09:52:25.907Z]     at async iB (/Users/ogrisel/.vscode/extensions/ms-vscode-remote.remote-containers-0.401.0/dist/spec-node/devContainersSpecCLI.js:485:4963)
[2025-04-07T09:52:25.907Z]     at async wrA (/Users/ogrisel/.vscode/extensions/ms-vscode-remote.remote-containers-0.401.0/dist/spec-node/devContainersSpecCLI.js:666:203)
[2025-04-07T09:52:25.907Z]     at async DrA (/Users/ogrisel/.vscode/extensions/ms-vscode-remote.remote-containers-0.401.0/dist/spec-node/devContainersSpecCLI.js:665:14830)
[2025-04-07T09:52:25.907Z]     at async /Users/ogrisel/.vscode/extensions/ms-vscode-remote.remote-containers-0.401.0/dist/spec-node/devContainersSpecCLI.js:485:1190
[2025-04-07T09:52:25.910Z] Stop (1372 ms): Run: /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Users/ogrisel/.vscode/extensions/ms-vscode-remote.remote-containers-0.401.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /Users/ogrisel/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --container-session-data-folder /tmp/devcontainers-736b008d-3df6-4ed2-857d-ebf2e221425b1744019543794 --workspace-folder /Users/ogrisel/code/scikit-learn --workspace-mount-consistency cached --gpu-availability detect --id-label devcontainer.local_folder=/Users/ogrisel/code/scikit-learn --id-label devcontainer.config_file=/Users/ogrisel/code/scikit-learn/.devcontainer/devcontainer.json --log-level debug --log-format json --config /Users/ogrisel/code/scikit-learn/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root --include-configuration --include-merged-configuration
[2025-04-07T09:52:25.910Z] Exit code 1
[2025-04-07T09:52:25.913Z] Command failed: /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Users/ogrisel/.vscode/extensions/ms-vscode-remote.remote-containers-0.401.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /Users/ogrisel/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --container-session-data-folder /tmp/devcontainers-736b008d-3df6-4ed2-857d-ebf2e221425b1744019543794 --workspace-folder /Users/ogrisel/code/scikit-learn --workspace-mount-consistency cached --gpu-availability detect --id-label devcontainer.local_folder=/Users/ogrisel/code/scikit-learn --id-label devcontainer.config_file=/Users/ogrisel/code/scikit-learn/.devcontainer/devcontainer.json --log-level debug --log-format json --config /Users/ogrisel/code/scikit-learn/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root --include-configuration --include-merged-configuration
[2025-04-07T09:52:25.913Z] Exit code 1

I think this is related to devcontainers/images#545.

So maybe we should at least document the purpose of this file, namely, to be used to open the scikit-learn project via the GitHub Codespaces editor.

@ogrisel
Copy link
Member

ogrisel commented Apr 7, 2025

I am trying again after editing the json config to use base:debian instead of universal:2.

EDIT: the initial setup seems to be fine but you still end-up in a non working env:

vscode ➜ ~ $ micromamba activate sklearn-dev
critical libmamba Cannot activate, prefix does not exist at: '/home/vscode/micromamba/envs/sklearn-dev'
vscode ➜ ~ $ ls /home/vscode/micromamba/
conda-meta  envs  etc
vscode ➜ ~ $ ls /home/vscode/micromamba/envs/

So we should definitely manage expectations and let users now that this devcontainer config is only meant to be used via GitHub Codespaces and not intended for local dev with VS Code.

@betatim
Copy link
Member

betatim commented Apr 7, 2025

After a quick conversation with perplexity.ai it seems like there is no way to have a devcontainer setup that is only used by code spaces and does not lead to a prompt by VS Code when used locally. But maybe VS Code remembers your preference? Said differently: it would be nice to have a documentation for people on how to stop VS Code asking you to use a devcontainer every time you start your editor.

I tried to experiment with this locally but I never get prompted :-/ Maybe because I don't have docker installed on my laptop?

I think having an easy way to avoid being prompted every time would be nice for users (and not trivial to find out how to do this) and would reduce the number of people who use the devcontainer. The latter might be important unless we want people to use the container also locally, in which case we need to somehow get ready to answer questions about things that go wrong. I've used devcontainers a bit for cuml, and while it was nice at first to solve setup problems, over time you discover more and more things that you need to "fix up" (e.g. ssh key forwarding/sharing for signed git commits, accessing local directories with datasets, etc - none of these are rocket science, but also not 1min jobs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants