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

Fix tests #50

Closed
wants to merge 4 commits into from
Closed
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
10 changes: 8 additions & 2 deletions api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@
"outputs": [],
"source": [
"import json, os, requests, time\n",
"from getpass import getpass\n",
"\n",
"# Before you begin, get your API key from https://cloud.ionq.com/settings/keys\n",
"\n",
"# If your API key is stored as \"IONQ_API_KEY\" in your local environment, this\n",
"# should find it. Otherwise you'll be prompted to enter your API key manually.\n",
"\n",
"api_key = os.getenv('IONQ_API_KEY') or getpass('Enter your IonQ API key: ')"
"api_key = os.getenv('IONQ_API_KEY')\n",
"\n",
"if not api_key:\n",
" try:\n",
" from getpass import getpass\n",
" api_key = getpass('Enter your IonQ API key: ')\n",
" except:\n",
" raise RuntimeError(\"API key is not set and input is not supported in this environment. Please set the IONQ_API_KEY environment variable.\")"
]
},
{
Expand Down
10 changes: 8 additions & 2 deletions cirq.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,20 @@
"outputs": [],
"source": [
"import cirq, cirq_ionq, matplotlib.pyplot as plt, os\n",
"from getpass import getpass\n",
"\n",
"# Before you begin, get your API key from https://cloud.ionq.com/settings/keys\n",
"\n",
"# If your API key is stored as \"IONQ_API_KEY\" in your local environment, this\n",
"# should find it. Otherwise you'll be prompted to enter your API key manually.\n",
"\n",
"api_key = os.getenv('IONQ_API_KEY') or getpass('Enter your IonQ API key: ')\n",
"api_key = os.getenv('IONQ_API_KEY')\n",
"\n",
"if not api_key:\n",
" try:\n",
" from getpass import getpass\n",
" api_key = getpass('Enter your IonQ API key: ')\n",
" except:\n",
" raise RuntimeError(\"API key is not set and input is not supported in this environment. Please set the IONQ_API_KEY environment variable.\")\n",
"\n",
"service = cirq_ionq.Service(api_key=api_key, default_target='simulator')"
]
Expand Down
12 changes: 9 additions & 3 deletions cuda-quantum/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@
"outputs": [],
"source": [
"import cudaq\n",
"\n",
"import os\n",
"from getpass import getpass\n",
"\n",
"api_key = os.getenv('IONQ_API_KEY') or getpass('Enter your IonQ API key: ')\n",
"api_key = os.getenv('IONQ_API_KEY')\n",
"\n",
"if not api_key:\n",
" try:\n",
" from getpass import getpass\n",
" api_key = getpass('Enter your IonQ API key: ')\n",
" except:\n",
" raise RuntimeError(\"API key is not set and input is not supported in this environment. Please set the IONQ_API_KEY environment variable.\")\n",
"\n",
"os.environ['IONQ_API_KEY'] = api_key # Remove when set_target takes api_key\n",
"cudaq.set_target('ionq', qpu='simulator')"
]
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies:
- pennylane
- pennylane-ionq
- projectq
- qbraid[runtime]
- cuda-quantum
- pylatexenc
- requests
13 changes: 9 additions & 4 deletions pennylane.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,21 @@
"outputs": [],
"source": [
"import pennylane as qml\n",
"\n",
"import os\n",
"from getpass import getpass\n",
"\n",
"# Before you begin, get your API key from https://cloud.ionq.com/settings/keys\n",
"\n",
"# If your API key is stored as \"IONQ_API_KEY\" in your local environment, this\n",
"# should find it. Otherwise you'll be prompted to enter your API key manually.\n",
" \n",
"api_key = os.getenv('IONQ_API_KEY') or getpass('Enter your IonQ API key: ')\n",
"api_key = os.getenv('IONQ_API_KEY')\n",
"\n",
"if not api_key:\n",
" try:\n",
" from getpass import getpass\n",
" api_key = getpass('Enter your IonQ API key: ')\n",
" except:\n",
" raise RuntimeError(\"API key is not set and input is not supported in this environment. Please set the IONQ_API_KEY environment variable.\")\n",
"\n",
"# We need to specify the device where the circuit will be executed. In\n",
"# this case we're using the `ionq.simulator`, but if you have QPU access you\n",
Expand Down Expand Up @@ -123,7 +128,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
15 changes: 10 additions & 5 deletions projectq.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
"outputs": [],
"source": [
"import os\n",
"from getpass import getpass\n",
"\n",
"import projectq.setups.ionq\n",
"from projectq import MainEngine\n",
"from projectq.backends import IonQBackend\n",
Expand All @@ -47,16 +45,23 @@
"# If your API key is stored as \"IONQ_API_KEY\" in your local environment, this\n",
"# should find it. Otherwise you'll be prompted to enter your API key manually.\n",
" \n",
"token = os.getenv('IONQ_API_KEY') or getpass('Enter your IonQ API key: ')\n",
"api_key = os.getenv('IONQ_API_KEY')\n",
"\n",
"if not api_key:\n",
" try:\n",
" from getpass import getpass\n",
" api_key = getpass('Enter your IonQ API key: ')\n",
" except:\n",
" raise RuntimeError(\"API key is not set and input is not supported in this environment. Please set the IONQ_API_KEY environment variable.\")\n",
"\n",
"# We need to specify the device where the circuit will be executed. In this \n",
"# case we're using the `ionq_simulator`, but if you have QPU access you can\n",
"# specify it here to run the job on a QPU directly.\n",
"\n",
"device = 'ionq_simulator'\n",
"\n",
"backend = IonQBackend(token=token, device=device)\n",
"compiler_engines = projectq.setups.ionq.get_engine_list(token=token, device=device)\n",
"backend = IonQBackend(token=api_key, device=device)\n",
"compiler_engines = projectq.setups.ionq.get_engine_list(token=api_key, device=device)\n",
"eng = MainEngine(backend, engine_list=compiler_engines)"
]
},
Expand Down
10 changes: 8 additions & 2 deletions qbraid.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@
"outputs": [],
"source": [
"import os\n",
"from getpass import getpass\n",
"from qbraid.runtime.ionq import IonQProvider\n",
"\n",
"# Before you begin, get your API key from https://cloud.ionq.com/settings/keys\n",
"\n",
"# If your API key is stored as \"IONQ_API_KEY\" in your local environment, this\n",
"# should find it. Otherwise you'll be prompted to enter your API key manually.\n",
"\n",
"api_key = os.getenv(\"IONQ_API_KEY\") or getpass(\"Enter your IonQ API key: \")\n",
"api_key = os.getenv('IONQ_API_KEY')\n",
"\n",
"if not api_key:\n",
" try:\n",
" from getpass import getpass\n",
" api_key = getpass('Enter your IonQ API key: ')\n",
" except:\n",
" raise RuntimeError(\"API key is not set and input is not supported in this environment. Please set the IONQ_API_KEY environment variable.\")\n",
"\n",
"provider = IonQProvider(api_key=api_key)"
]
Expand Down
Loading
Loading