Skip to content

Commit

Permalink
update links for colab (#48)
Browse files Browse the repository at this point in the history
* update links for colab

* test common versions of python

* fix indentation

* lol requests not requirements

* pin ubuntu version

* test specifying the architecture

* test to remove python3.12

* pip freeze to help pip

* oh good luck

* maybe 3.9 cant resolve

* test old deps with no dep checking

* upgrade pip

* dont specify versions

* revert requirements and actions

* try using the conda package manager

* remove pip requirements

* attempt to fix conda init error

* remove existing conda envs

* add pip dependency to conda

* pls work conda pls
  • Loading branch information
splch committed Mar 13, 2024
1 parent 728c721 commit c95c1b4
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 44 deletions.
47 changes: 33 additions & 14 deletions .github/workflows/test_notebooks.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
name: Test Notebooks

on: push
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Check out code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: myenv
environment-file: environment.yml
python-version: "3.11"
auto-activate-base: false

- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Prepare Conda environment
shell: bash -l {0}
run: |
if conda env list | grep -q 'myenv'; then
echo "Environment 'myenv' already exists, updating environment"
conda env update --name myenv --file environment.yml --prune
else
echo "Creating new environment 'myenv'"
conda env create -f environment.yml
fi
- name: Run notebook tests
run: python tests/test_notebooks.py
env:
IONQ_API_KEY: ${{ secrets.IONQ_API_KEY }}
- name: Run notebook tests
shell: bash -l {0}
run: |
conda activate myenv
python tests/test_notebooks.py
env:
IONQ_API_KEY: ${{ secrets.IONQ_API_KEY }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ share/python-wheels/
# Distribution / packaging
.Python
env/
venv/
ionq/
build/
develop-eggs/
Expand Down
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ This repository contains Python samples exploring quantum computing on IonQ's pl

If you're looking for advanced and in-depth examples for a given library that implement a specific algorithm, check out some of the other projects in the [ionq-samples](https://github.com/ionq-samples) organization on GitHub.

----
---

## Prerequisites

There are a wide variety of ways to run these notebooks, but for starters you'll need:

1. [Python](https://www.python.org/downloads/) installed, using a version between 3.8 and 3.11.
1. A [virtual environment](https://docs.python.org/3/library/venv.html) to help ensure your dependencies don't conflict with anything else you have installed.
1. An [IonQ API key](https://cloud.ionq.com/settings/keys), which optionally you can store as an environment variable for ease of use. Our notebooks expect to find it stored as `IONQ_API_KEY`.
1. An installation of the library you're wanting to run. To install all the libraries at once, run `pip install -r requirements.txt` from the root directory of this repository.
2. A [virtual environment](https://docs.python.org/3/library/venv.html) to help ensure your dependencies don't conflict with anything else you have installed.
3. An [IonQ API key](https://cloud.ionq.com/settings/keys), which optionally you can store as an environment variable for ease of use. Our notebooks expect to find it stored as `IONQ_API_KEY`.
4. An installation of the library you're wanting to run. To install all the libraries at once using Conda, run the following command from the root directory of this repository:

----
```shell
conda env create -f environment.yml
```

---

## Usage

Expand All @@ -27,21 +31,24 @@ If you're unfamiliar with Jupyter but you're used to a traditional IDE or code e

1. From your terminal, navigate to this repository and run the following command from within this directory:

```shell
jupyter notebook
```
```shell
jupyter notebook
```

1. Once the server is started, it should automatically open your browser. In case it doesn't, you can navigate directly to it by pointing your browser at [http://localhost:8888](http://localhost:8888)
1. Navigate to the location of a `.ipynb` file and open it. If you don't have a particular SDK in mind, we recommend starting with `qiskit`, as its the most commonly used library today.

#### VS Code

1. Open the folder in VS Code and navigate to a `.ipynb` file and open it.
1. If it's your first time using it, it will suggest a number of plugins that you may need to install before the notebook will be fully functional.
1. At the top-right of the screen, click on `Select Kernel` and choose an appropriate Python runtime to run the notebook in.
#### Cloud
1. Open the notebook by clicking on the ![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg) badge located in each notebook. Or open this repository in [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ionq-samples/getting-started/HEAD)
----
---
## Support
Expand Down
4 changes: 2 additions & 2 deletions api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Direct API Access\n",
"\n",
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/api/main.ipynb)\n",
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/api.ipynb)\n",
"\n",
"IonQ offers a set of API resources that allow you to submit and manage jobs directly. This notebook offers a few simple examples, but visit [docs.ionq.com](https://docs.ionq.com) for a complete guide with additional resources and functionality."
]
Expand Down Expand Up @@ -176,7 +176,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.8"
},
"orig_nbformat": 4
},
Expand Down
6 changes: 3 additions & 3 deletions cirq.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"source": [
"# Cirq\n",
"\n",
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/cirq/main.ipynb)\n",
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/cirq.ipynb)\n",
"\n",
"[Cirq](https://github.com/quantumlib/Cirq) is an open-source Python library developed by Google for designing, simulating, and running quantum circuits on quantum computers."
"[Cirq](https://github.com/quantumlib/Cirq) is a Python library for writing, manipulating, and optimizing quantum circuits and running them against quantum computers and simulators. It is designed to be flexible, and is suitable for use in a variety of quantum computing tasks."
]
},
{
Expand Down Expand Up @@ -122,7 +122,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
22 changes: 22 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: myenv
channels:
- conda-forge
- defaults
dependencies:
- python=3.11
- pip
- matplotlib
- jupyter
# Add other dependencies here, for Conda packages.
- pip:
# Pip-only packages here, if any.
- qiskit
- qiskit-ionq
- cirq
- cirq-ionq
- pennylane
- pennylane-ionq
- projectq
- cuda-quantum
- pylatexenc
- requests
6 changes: 4 additions & 2 deletions pennylane.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"source": [
"# PennyLane\n",
"\n",
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/pennylane/main.ipynb)"
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/pennylane.ipynb)\n",
"\n",
"[PennyLane](https://pennylane.ai/) is a cross-platform Python library for quantum machine learning, automatic differentiation, and optimization of hybrid quantum-classical computations. It is designed to work with existing quantum computing hardware and simulators, and integrates seamlessly with machine learning libraries such as TensorFlow and PyTorch."
]
},
{
Expand Down Expand Up @@ -121,7 +123,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions projectq.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"source": [
"# ProjectQ\n",
"\n",
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/projectq/main.ipynb)\n",
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/projectq.ipynb)\n",
"\n",
"ProjectQ is an open-source software framework for quantum computing that allows users to design, simulate, and optimize quantum circuits on various backends."
"[ProjectQ](https://projectq.ch/) is an open-source software framework for quantum computing that allows users to design, simulate, and optimize quantum circuits on various backends."
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion qiskit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"source": [
"# Getting Started with Qiskit\n",
"\n",
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/qiskit/main.ipynb)\n",
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/qiskit.ipynb)\n",
"\n",
"[Qiskit](https://qiskit.org/) is an open-source quantum computing framework developed by IBM for building, simulating, and running quantum circuits on real and simulated quantum devices."
]
Expand Down
11 changes: 0 additions & 11 deletions requirements.txt

This file was deleted.

0 comments on commit c95c1b4

Please sign in to comment.