Skip to content
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

Codespaces support for v4 #1635

Open
wants to merge 1 commit into
base: v4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// For use with Visual Studio Code
{
"name": "${localWorkspaceFolderBasename}",
"dockerComposeFile": [
"../docker-compose.yaml",
"docker-compose.extend.yaml"
],
"remoteUser": "rigetti",
"service": "lab",
"workspaceFolder": "/home/rigetti/${localWorkspaceFolderBasename}",
"shutdownAction": "stopCompose",
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
],
"settings": {
"python.defaultInterpreterPath": "/home/quil/.venv/${localWorkspaceFolderBasename}/bin/python",
"python.pythonpath": "/home/rigetti/.venv/${localWorkspaceFolderBasename}/bin/python"
}
}
5 changes: 5 additions & 0 deletions .devcontainer/docker-compose.extend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: '3'
services:
lab:
# Overrides default command so things don't shut down after the process ends.
command: /bin/bash -c "while sleep 1000; do :; done"
85 changes: 59 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,67 @@
# use multi-stage builds to independently pull dependency versions
ARG quilc_version=1.20.0
ARG qvm_version=1.17.1
ARG python_version=3.7
# syntax=docker/dockerfile:1.3
ARG PYTHON_VERSION=3.9
FROM python:$PYTHON_VERSION AS dev

# use multi-stage builds to independently pull dependency versions
FROM rigetti/quilc:$quilc_version as quilc
FROM rigetti/qvm:$qvm_version as qvm
FROM python:$python_version-buster
USER root

ARG pyquil_version
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y \
curl \
wget \
git \
build-essential \
software-properties-common \
bash-completion \
libblas-dev \
libffi-dev \
liblapack-dev \
libzmq3-dev \
sudo

# copy over the pre-built quilc binary from the first build stage
COPY --from=quilc /src/quilc/quilc /src/quilc/quilc
# Create the docker user 'rigetti'
ENV USER=rigetti
ARG UID=1000
ARG GID=1000
RUN addgroup --gid ${GID} ${USER} \
&& adduser \
--disabled-password \
--gecos ${USER} \
--gid ${GID} \
--uid ${UID} \
--home /home/rigetti/ \
${USER} \
&& usermod -aG sudo ${USER} \
&& passwd -d ${USER}

# copy over the pre-built qvm binary from the second build stage
COPY --from=qvm /src/qvm/qvm /src/qvm/qvm
# Create our project directory and switch to it
ARG PROJECT_SLUG=pyquil
ARG SRC_DIR=.
ENV APP_DIR=/home/${USER}/${PROJECT_SLUG}
RUN mkdir -p ${APP_DIR}/${SRC_DIR} && chown -R ${USER}:${USER} ${APP_DIR}/${SRC_DIR}

# install the missing apt packages that aren't copied over
RUN apt-get update && apt-get -yq dist-upgrade && \
apt-get install --no-install-recommends -yq \
git libblas-dev libffi-dev liblapack-dev libzmq3-dev && \
rm -rf /var/lib/apt/lists/*
WORKDIR ${APP_DIR}/${SRC_DIR}

# install ipython
RUN pip install --no-cache-dir ipython
USER ${USER}

# install pyquil
RUN pip install pyquil==$pyquil_version
# Install poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="${PATH}:/home/${USER}/.local/bin"
RUN mkdir -p /home/${USER}/.config/pypoetry/

# use an entrypoint script to add startup commands (qvm & quilc server spinup)
COPY ./entrypoint.sh /src/pyquil/entrypoint.sh
ENTRYPOINT ["/src/pyquil/entrypoint.sh"]
CMD ["ipython"]
# Install the package
COPY --chown=${USER}:${USER} ${SRC_DIR}/README.md ${SRC_DIR}/pyproject.toml ${SRC_DIR}/poetry.lock ./
COPY --chown=${USER}:${USER} --chmod=775 ${SRC_DIR}/pyquil/__init__.py ./pyquil/__init__.py
RUN poetry install \
--no-interaction \
--no-ansi \
--extras latex
RUN rm -r ./pyquil

# Set up the venv
RUN mkdir ${HOME}/.venv/ && ln -s $(poetry env info -p) /home/${USER}/.venv/${PROJECT_SLUG}
ENV VIRTUAL_ENV=/home/${USER}/.venv/${PROJECT_SLUG}
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

WORKDIR ${APP_DIR}
ENV SHELL /bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dockerfile is used for the Forest SDK Docker image. Is there any way we can provide a different dockerfile for codespaces?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we could do that

38 changes: 19 additions & 19 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
version: '3'
version: '3.5'

services:
lab:
build:
context: .
dockerfile: Dockerfile
args:
PYTHON_VERSION: ${PYTHON_VERSION:-3.9}
volumes:
- .:/home/rigetti/pyquil/
environment:
- QCS_SETTINGS_APPLICATIONS_PYQUIL_QVM_URL=http://qvm:5000
- QCS_SETTINGS_APPLICATIONS_PYQUIL_QUILC_URL=tcp://quilc:5555
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These environment variables should be QCS_APPLICATIONS_QVM_URL QCS_APPLICATIONS_QUILC_URL

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Will update since targeting v4

quilc:
image: rigetti/quilc
command: -S
expose:
command:
- -R
- -p
- "5555"
ports:
- '5555:5555'
networks:
- test

- -P
qvm:
image: rigetti/qvm
command: -S
expose:
command:
- -p
- "5000"
ports:
- '5000:5000'
networks:
- test

networks:
test:
driver: bridge

- -S
11 changes: 0 additions & 11 deletions entrypoint.sh

This file was deleted.