From 1fe9293295512551a479bf06554d1bcc69563509 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 10 Jan 2025 17:06:26 -0500 Subject: [PATCH] Migrate devcontainer base to https://github.com/inference-labs-inc/tensor-tools --- .devcontainer/Dockerfile | 111 +------------------------------- .devcontainer/devcontainer.json | 33 +++++----- 2 files changed, 16 insertions(+), 128 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 59827602..9841d998 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,113 +1,4 @@ -FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/base:noble - -# Install dependencies and some nice to have tools -RUN apt update && \ - apt install -y \ - python3-dev \ - python3-venv \ - build-essential \ - jq \ - git \ - curl \ - make \ - clang \ - pkg-config \ - libssl-dev \ - llvm \ - libudev-dev \ - protobuf-compiler \ - byobu \ - fish \ - wget \ - && rm -rf /var/lib/apt/lists/* - -# Install Rust -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -ENV PATH="/root/.cargo/bin:${PATH}" - -# Install subtensor -RUN git clone https://github.com/opentensor/subtensor.git && \ - cd subtensor && \ - git checkout v1.1.6 && \ - cargo build --workspace --profile=release --features pow-faucet --manifest-path "Cargo.toml" - -# Install Jolt -ENV RUST_TOOLCHAIN=nightly-2024-09-30 -RUN rustup toolchain install ${RUST_TOOLCHAIN} && \ - cargo +${RUST_TOOLCHAIN} install --git https://github.com/a16z/jolt --force --bins jolt - -# Install node et al. -RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash && \ - export NVM_DIR="/root/.nvm" && \ - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \ - [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && \ - nvm install 20 && \ - npm install --prefix /root/.snarkjs snarkjs@0.7.4 - -# Use a venv because of https://peps.python.org/pep-0668/ -RUN python3 -m venv /opt/venv && \ - /opt/venv/bin/python3 -m pip install --upgrade pip -ENV PATH="/opt/venv/bin:${PATH}" - -# Install Python dependencies, and some more nice to have tools -COPY requirements.txt /opt/omron/requirements.txt -RUN TORCH_VERSION=$(grep "^torch" /opt/omron/requirements.txt) && \ - pip3 install $TORCH_VERSION --index-url https://download.pytorch.org/whl/cpu && \ - pip3 install -r /opt/omron/requirements.txt -RUN pip3 install bittensor-cli==8.3.1 bpython ptpython pipdeptree pysnooper coverage - -# Set flags for local subtensor -ENV WPATH="--wallet.path /root/.bittensor/wallets/" -ENV LOCALNET="--subtensor.chain_endpoint ws://127.0.0.1:9946" - -# Create wallets -RUN btcli wallet new_coldkey --no-use-password --n-words 15 $WPATH --wallet.name owner && \ - btcli wallet new_hotkey --no-use-password --n-words 15 $WPATH --wallet.name owner --wallet.hotkey default && \ - btcli wallet new_coldkey --no-use-password --n-words 15 $WPATH --wallet.name miner && \ - btcli wallet new_hotkey --no-use-password --n-words 15 $WPATH --wallet.name miner --wallet.hotkey default && \ - btcli wallet new_coldkey --no-use-password --n-words 15 $WPATH --wallet.name validator && \ - btcli wallet new_hotkey --no-use-password --n-words 15 $WPATH --wallet.name validator --wallet.hotkey default - -# Mint some tokens -RUN cd subtensor && \ - BUILD_BINARY=0 ./scripts/localnet.sh > /dev/null 2>&1 & \ - sleep 5 && \ - yes | btcli wallet faucet --wallet.name owner $WPATH $LOCALNET & \ - sleep 60 && \ - pkill -2 localnet ; \ - pkill -2 subtensor ; \ - sleep 1 - -RUN cd subtensor && \ - BUILD_BINARY=0 ./scripts/localnet.sh --no-purge > /dev/null 2>&1 & \ - sleep 5 && \ - yes | btcli wallet faucet --wallet.name miner $WPATH $LOCALNET & \ - sleep 60 && \ - pkill -2 localnet ; \ - pkill -2 subtensor ; \ - sleep 1 - -RUN cd subtensor && \ - BUILD_BINARY=0 ./scripts/localnet.sh --no-purge > /dev/null 2>&1 & \ - sleep 5 && \ - yes | btcli wallet faucet --wallet.name validator $WPATH $LOCALNET & \ - sleep 60 && \ - pkill -2 localnet ; \ - pkill -2 subtensor ; \ - sleep 1 - -# Register the subnet -RUN cd subtensor && \ - BUILD_BINARY=0 ./scripts/localnet.sh --no-purge > /dev/null 2>&1 & \ - sleep 5 && \ - btcli subnet create --wallet.name owner --no-prompt $WPATH $LOCALNET && \ - btcli subnet register --wallet.name miner --no-prompt --netuid 1 --wallet.hotkey default $WPATH $LOCALNET && \ - btcli subnet register --wallet.name validator --no-prompt --netuid 1 --wallet.hotkey default $WPATH $LOCALNET && \ - btcli root nominate --wallet.name validator --no-prompt --wallet.hotkey default $WPATH $LOCALNET && \ - btcli stake add --wallet.name validator --no-prompt --amount 100 --wallet.hotkey default $WPATH $LOCALNET && \ - pkill -2 localnet ; \ - pkill -2 subtensor ; \ - sleep 1 +FROM ghcr.io/inference-labs-inc/bittensor-devcontainer:latest # Add scripts to start and stop the localnet, and aliases for common btcli commands RUN echo "#!/usr/bin/env bash" > /start_localnet.sh && \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d2fc74e1..170c5f6a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,24 +9,15 @@ "context": "..", "dockerfile": "Dockerfile" }, - "remoteUser": "root", - "customizations": { - "vscode": { - "settings": { - "python.defaultInterpreterPath": "/opt/venv/bin/python" - } - } - }, - "runArgs": ["--platform=linux/amd64"], - "features": { - "ghcr.io/devcontainers/features/python:1": { - "installTools": true, - "version": "os-provided" - } - } + // "runArgs": ["--platform=linux/amd64"], // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, + // "features": { + // "ghcr.io/devcontainers/features/python:1": { + // "installTools": true, + // "version": "os-provided" + // } + // }, // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], @@ -35,8 +26,14 @@ // "postCreateCommand": "uname -a", // Configure tool-specific properties. - // "customizations": {}, + "customizations": { + "vscode": { + "settings": { + "python.defaultInterpreterPath": "/opt/venv/bin/python" + } + } + }, // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" + "remoteUser": "root" }