{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Authentication & Quotas\n", "\n", "Quantinuum Nexus API usage requires you to have valid authentication tokens. You can obtain these by logging in with `qnexus`. \n", "\n", "This isn't required in the Nexus Lab, where authentication is automatically taken care of." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import qnexus as qnx" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`qnexus` provides the following ways of logging in.\n", "\n", "\n", "```python\n", "# Login with the browser\n", "qnx.login()\n", "```\n", "\n", "```python\n", "# Login by passing your credentials\n", "qnx.login_with_credentials()\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You'll now be authenticated and can use `qnexus`. \n", "\n", "Please note that in order to collaborate on Projects with others, you'll also need to have appropriate Role assignments set, see [Teams & Roles](./teams_roles.ipynb)\n", "\n", "\n", "```python\n", "# Logout\n", "qnx.logout()\n", "```\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Quotas\n", "\n", "In addition to being authenticated, some operations in Nexus require you to have an appropriate `Quota`. These operations include:\n", "\n", "- using the Nexus Lab\n", "- compiling `Circuit`s on Nexus\n", "- simulating `Circuit` execution on Nexus\n", "- storage of Project data in the Nexus Database\n", "\n", "Your simulation, compilation and Nexus Lab quota will renew each month, but your database usage quota will not renew.\n", "\n", "In addition, if you have access to Quantinuum H-series devices you'll need to have a HQC quota." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# See your available quotas (including your usage)\n", "qnx.quotas.get_all().df()\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Check if you have required quota or not\n", "if qnx.quotas.check_quota(name=\"compilation\"):\n", " print(\"Compilation quota OK!\")\n", "else:\n", " print(\"No more compilation quota!\")\n" ] } ], "metadata": { "kernelspec": { "display_name": "qnexus-Rou6F43i-py3.11", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.8" } }, "nbformat": 4, "nbformat_minor": 2 }