From 0f9ba1196fdf77a564a2ecec8e06d44c6615a94a Mon Sep 17 00:00:00 2001 From: derpyplops Date: Tue, 4 Apr 2023 11:17:02 +0800 Subject: [PATCH] Create devcontainer (#150) * devcontainer * add button * change to python 3.10 --- .devcontainer/Dockerfile | 51 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 47 ++++++++++++++++++++++++++++++ README.md | 10 +++++++ 3 files changed, 108 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..0d004b7a --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,51 @@ +# Use Nvidia Ubuntu 20 base (includes CUDA if a supported GPU is present) +# https://hub.docker.com/r/nvidia/cuda +FROM nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04@sha256:55211df43bf393d3393559d5ab53283d4ebc3943d802b04546a24f3345825bd9 + +ARG USERNAME +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# Create the user +# https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ + && usermod -a -G video user \ + && apt-get update \ + && apt-get install -y sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME + +ENV DEBIAN_FRONTEND=noninteractive + +# Install dependencies +RUN apt-get update && \ + apt-get -qq -y install \ + software-properties-common && \ + add-apt-repository ppa:deadsnakes/ppa && \ + apt-get update && \ + apt-get -qq -y install \ + build-essential \ + python3.10 \ + python3.10-dev \ + python3.10-distutils \ + python3.10-venv \ + curl \ + git \ + tmux + +# Update package list, add the deadsnakes PPA, and install dependencies + + +ENV PATH="$HOME/.local/bin:$PATH" + +# Install pip (we need the latest version not the standard Ubuntu version, to +# support modern wheels) +RUN sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3.10 get-pip.py + +# Set python aliases +RUN sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 +RUN sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 + +# User the new user +USER $USERNAME diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..bee3dbf8 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,47 @@ +{ + "name": "Python 3", + "build": { + "dockerfile": "Dockerfile", + "args": { + "USERNAME": "user" + } + }, + "customizations": { + "vscode": { + "settings": { + "python.formatting.autopep8Path": "autopep8", + "python.linting.mypyPath": "mypy", + "terminal.integrated.defaultProfile.linux": "tmux", + "terminal.integrated.profiles.linux": { + "bash": { + "path": "bash", + "icon": "terminal-bash" + }, + "tmux": { + "path": "bash", + "args": ["-c", "tmux new -ADs ${PWD##*/}"], + "icon": "terminal-tmux" + } + } + }, + "extensions": [ + "davidanson.vscode-markdownlint", + "donjayamanne.githistory", + "donjayamanne.python-extension-pack", + "github.vscode-pull-request-github", + "ms-python.python", + "ms-toolsai.jupyter", + "ms-vsliveshare.vsliveshare-pack", + "njpwerner.autodocstring", + "stkb.rewrap", + "streetsidesoftware.code-spell-checker", + "tushortz.python-extended-snippets", + "yzhang.markdown-all-in-one", + "elagil.pre-commit-helper", + "eamodio.gitlens" + ] + } + }, + "containerUser": "user", + "postCreateCommand": "pip install -e .[dev] --no-warn-script-location" +} diff --git a/README.md b/README.md index 9b9a94e2..a62a5243 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,16 @@ The hidden states resulting from `elk elicit` are cached as a HuggingFace datase ## Development Use `pip install pre-commit && pre-commit install` in the root folder before your first commit. +### Devcontainer + +[ + ![Open in Remote - Containers]( + https://img.shields.io/static/v1?label=Remote%20-%20Containers&message=Open&color=blue&logo=visualstudiocode + ) +]( + https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/EleutherAI/elk +) + ### Run tests ```bash pytest