To start using GitHub Codespaces with Leap, you must create a GitHub account, which you can get for free, and set up Codespaces to work with Leap.
Note: This article describes starting with a D-Wave example in GitHub, which already has the Ocean SDK installed; to start with a new GitHub repository, you must configure your codespace to use Ocean-Dev Docker Images.
Setting Up Codespaces to Work with Leap
When you create or open an existing repository, you must authorize the Ocean SDK to access your Leap account and then fetch your solver API token.
Open an Existing Repository in Codespaces
- From the main page of a GitHub repository, select the green Code button.
- Under the Codespaces tab, select the plus sign to open a new Codespace.
Note: If you already have a Codespace with the current repository, you can reopen, close, or delete that existing Codespace.
The repository opens in a new tab.
Authorize the Ocean SDK Access to Your Leap Account
To run the code, you need to authorize the Ocean SDK access to your Leap account. Specifically, the Ocean SDK needs to access your Solver API token.
-
In a terminal, type
dwave auth login --oob
(as shown below) and press Enter:
A window displays and asks if you want Code to open the external website with a URL that begins with https://cloud.dwavesys.com/leap. -
Click Open.
If you are not currently logged into Leap, a new tab opens and displays the Leap login page. - Enter your account credentials and log in.
- Click Authorize on the Leap Request for Permission tab, which asks for permission to access your Leap Solver API token.
- In the Authorization Code field, an authorization code is displayed. Click the Copy icon that is displayed above the authorization code.
-
Return to the terminal in Codespaces, paste the authorization code into the terminal at the prompt, and press Enter.
A confirmation message displays, as shown below.
Fetching Your Leap Solver API Token
Now that the Ocean SDK is allowed to access your Leap Solver API (SAPI) token, you can direct it to fetch that token. This is the final step which then allows you to access the D-Wave solvers.
- In the terminal, type
dwave config create --auto-token
and press Enter. - A message displays stating that a SAPI token was fetched from your Leap project and a configuration was saved.
You can now run the Python code and access the D-Wave solvers.
For more detailed information, see Leap Support for IDEs.
Comments
Please sign in to leave a comment.