Skip to content

Update start notebook to use get_engine instead of get_qcs_objects_for_notebook #6483

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

Merged
merged 9 commits into from
Mar 5, 2024
Merged
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
27 changes: 15 additions & 12 deletions docs/tutorials/google/start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,24 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "YoqI9GrOPExP",
"cellView": "form"
"id": "YoqI9GrOPExP"
},
"outputs": [],
"source": [
"# The Google Cloud Project id to use.\n",
"project_id = \"\" #@param {type:\"string\"}\n",
"\n",
"from cirq_google.engine.qcs_notebook import get_qcs_objects_for_notebook\n",
"# For virtual engine instances, set 'virtual=True' below.\n",
"qcs_objects = get_qcs_objects_for_notebook(project_id)\n",
"from cirq_google.engine import get_engine\n",
"from cirq_google.engine.qcs_notebook import authenticate_user\n",
"\n",
"engine = qcs_objects.engine\n",
"if not qcs_objects.signed_in:\n",
" print(\"ERROR: Please setup project_id in this cell or set the `GOOGLE_CLOUD_PROJECT` env var to your project id.\")\n",
" print(\"Using noisy simulator instead.\")\n"
"authenticate_user()\n",
"try:\n",
" engine = get_engine(project_id)\n",
"except Exception:\n",
" from cirq_google.engine.qcs_notebook import get_qcs_objects_for_notebook\n",
" print(\"Unable to connect to a hardware engine. Using a virtual instance instead.\")\n",
" qcs_objects = get_qcs_objects_for_notebook(project_id, virtual=True)\n",
" engine = qcs_objects.engine"
]
},
{
Expand Down Expand Up @@ -175,11 +177,11 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 24,
"metadata": {
"cellView": "both",
"id": "EQoTYZIEPa9S",
"outputId": "43c72568-3bc8-4b44-871b-b9db19c9e672",
"outputId": "beb04676-8404-4831-8d40-3291ee2d6127",
"colab": {
"base_uri": "https://localhost:8080/"
}
Expand Down Expand Up @@ -275,7 +277,8 @@
{
"cell_type": "code",
"source": [
"processors = [p.processor_id for p in engine.list_processors() if p.health() == 'OK']"
"processors = [p.processor_id for p in engine.list_processors() if p.health() == 'OK']\n",
"print(f\"Available processors: {processors}\")"
],
"metadata": {
"id": "rvMeXrC1wnQi"
Expand Down