From bd7c5e3a68357a6988c21e7a394b2beb44cf76f5 Mon Sep 17 00:00:00 2001 From: Andrew Meyer Date: Wed, 11 Aug 2021 16:53:15 -0700 Subject: [PATCH] New: Add binder image to run tutorials --- .dockerignore | 2 ++ CHANGELOG.md | 7 ++++++ Dockerfile | 38 ++++++++++++++++++++++++++++++ README.md | 14 +++++++++++ binder-requirements.txt | 4 ++++ docs/examples/GettingStarted.ipynb | 2 +- docs/examples/QAOA.ipynb | 2 +- 7 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 binder-requirements.txt diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3978a0f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.git +.gitignore diff --git a/CHANGELOG.md b/CHANGELOG.md index d881541..43d4fc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.4.3](https://github.com/rigetti/qiskit-rigetti/releases/tag/v0.4.3) + +### New + +- Added binder tutorials image + + ## [0.4.2](https://github.com/rigetti/qiskit-rigetti/releases/tag/v0.4.2) ### Updates diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ed61481 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM rigetti/forest:3.0.0 + +# install jupyter notebook and jupyter lab +COPY binder-requirements.txt binder-requirements.txt +RUN pip install --no-cache-dir -r binder-requirements.txt + +# create user with UID 1000 and associated home dir (required by binder) +ARG NB_USER=binder +ARG NB_UID=1000 +ENV USER ${NB_USER} +ENV NB_UID ${NB_UID} +ENV HOME /home/${NB_USER} +RUN adduser --disabled-password \ + --gecos "Default user" \ + --uid ${NB_UID} \ + ${NB_USER} + +WORKDIR ${HOME} + +# copy tutorials +COPY docs/examples/ examples/ + +# install qelib1.inc +ARG qelib1_version=0.16.2 +RUN curl -L -o ${HOME}/qelib1_LICENSE.txt https://raw.githubusercontent.com/Qiskit/qiskit-terra/$qelib1_version/LICENSE.txt +RUN curl -L -o ${HOME}/qelib1.inc https://raw.githubusercontent.com/Qiskit/qiskit-terra/$qelib1_version/qiskit/qasm/libs/qelib1.inc + +# transfer ownership of /home/binder to binder user +USER root +RUN chown -R ${NB_UID} ${HOME} +USER ${NB_USER} + +# signal that we need to publish port 8888 to run the notebook server +EXPOSE 8888 + +# run the notebook server +CMD ["jupyter", "lab", "--ip=0.0.0.0"] + diff --git a/README.md b/README.md index 2f2df2f..9179c4f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,23 @@ [![Tests](https://github.com/rigetti/qiskit-rigetti/actions/workflows/test.yml/badge.svg)](https://github.com/rigetti/qiskit-rigetti/actions/workflows/test.yml) [![Documentation Status](https://readthedocs.org/projects/qiskit-rigetti/badge/?version=latest)](https://qiskit-rigetti.readthedocs.io/en/latest/?badge=latest) [![pypi](https://img.shields.io/pypi/v/qiskit-rigetti.svg)](https://pypi.org/project/qiskit-rigetti/) +[![Binder](https://mybinder.org/badge_logo.svg)][binder] # Rigetti Provider for Qiskit +## Try It Out + +To try out this library, you can run example notebooks in a pre-made [binder][binder]. Alternately, you can run the following to build and run the image locally: + +```bash +docker build -t qiskit-tutorials . +docker run --rm -p 8888:8888 qiskit-tutorials +``` + +then click on the link that is displayed after the container starts up. + +[binder]: https://mybinder.org/v2/gh/rigetti/qiskit-rigetti/main?filepath=examples + ## Pre-requisites 1. Install [Docker](https://www.docker.com/products/docker-desktop) diff --git a/binder-requirements.txt b/binder-requirements.txt new file mode 100644 index 0000000..9e245ab --- /dev/null +++ b/binder-requirements.txt @@ -0,0 +1,4 @@ +qiskit-rigetti==0.4.* +qiskit[visualization] +notebook +jupyterlab diff --git a/docs/examples/GettingStarted.ipynb b/docs/examples/GettingStarted.ipynb index 2969d36..fed1d8d 100644 --- a/docs/examples/GettingStarted.ipynb +++ b/docs/examples/GettingStarted.ipynb @@ -45,7 +45,7 @@ "outputs": [], "source": [ "provider = RigettiQCSProvider()\n", - "backend = provider.get_simulator(num_qubits=2, noisy=True) # or provider.get_backend(name=\"Aspen-9\")" + "backend = provider.get_simulator(num_qubits=2, noisy=True) # or provider.get_backend(name=\"Aspen-9\") when running via QCS" ] }, { diff --git a/docs/examples/QAOA.ipynb b/docs/examples/QAOA.ipynb index 62d8342..e3d45f3 100644 --- a/docs/examples/QAOA.ipynb +++ b/docs/examples/QAOA.ipynb @@ -577,7 +577,7 @@ " p: int,\n", " Number of repetitions of unitaries\n", " \"\"\"\n", - " backend = provider.get_simulator(num_qubits=len(G.nodes), noisy=False) # or provider.get_backend(name='Aspen-9')\n", + " backend = provider.get_simulator(num_qubits=len(G.nodes), noisy=False) # or provider.get_backend(name='Aspen-9') when running via QCS\n", " \n", " def execute_circ(theta):\n", " \n",