From 4b551067eaae406826ae5f06d844025e45c2e72e Mon Sep 17 00:00:00 2001 From: rryoung98 Date: Fri, 5 Apr 2024 11:31:19 -0500 Subject: [PATCH] update credential setup in fireopal --- qbraid_lab/fire_opal/get-started.ipynb | 45 +++++++++++++++++++++----- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/qbraid_lab/fire_opal/get-started.ipynb b/qbraid_lab/fire_opal/get-started.ipynb index b3404b6..3c16707 100644 --- a/qbraid_lab/fire_opal/get-started.ipynb +++ b/qbraid_lab/fire_opal/get-started.ipynb @@ -315,9 +315,39 @@ "Note that the code below requires your IBM Quantum API token. Visit [IBM Quantum](https://quantum.ibm.com/) to sign up for an account and [obtain your access credentials](https://docs.quantum-computing.ibm.com/run/account-management)." ] }, + { + "cell_type": "markdown", + "id": "99cf3b28", + "metadata": {}, + "source": [ + "Add your IBM and Q-CTRL credentials as environment variables." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f9782358", + "metadata": {}, + "outputs": [], + "source": [ + "%set_env IBM_TOKEN=YOUR_IBM_TOKEN\n", + "%set_env QCTRL_API_KEY=YOUR_QCTRL_API_KEY" + ] + }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, + "id": "0c83cce7", + "metadata": {}, + "outputs": [], + "source": [ + "ibm_token = os.getenv(\"IBM_TOKEN\")\n", + "api_key = os.getenv(\"QCTRL_API_KEY\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, "id": "ef17a083", "metadata": {}, "outputs": [], @@ -327,15 +357,14 @@ "hub = \"ibm-q\"\n", "group = \"open\"\n", "project = \"main\"\n", - "token = \"YOUR_IBM_TOKEN\"\n", - "credentials = fireopal.credentials.make_credentials_for_ibmq(\n", - " token=token, hub=hub, group=group, project=project\n", - ")\n", + "fireopal.authenticate_qctrl_account(api_key=api_key)\n", "\n", - "QiskitRuntimeService.save_account(\n", - " token, instance=hub + \"/\" + group + \"/\" + project, overwrite=True\n", + "credentials = fireopal.credentials.make_credentials_for_ibmq(\n", + " token=ibm_token, hub=hub, group=group, project=project\n", ")\n", - "service = QiskitRuntimeService()" + "service = QiskitRuntimeService(\n", + " token=ibm_token, instance=hub + \"/\" + group + \"/\" + project, channel=\"ibm_quantum\"\n", + ")" ] }, {