How Do I Get Started with GitHub Codespaces?

To start using GitHub Codespaces with the Leap™ service, you must create a GitHub account, which you can get for free, and set up a repository and its codespace to work with the Leap service.

Set Up a Repository and Codespace to Work with the Leap Service

For a repository and codespace to work with the Leap service, the repository must have the Ocean™ SDK installed and you must authorize the Ocean SDK to access your Leap account and then fetch your solver API token. D-Wave™ example repositories already have the Ocean SDK installed.

Open an Existing D-Wave Examples Repository in a Codespace

  1. From the main page of a dwave-examples GitHub repository, select the green Code button.
  2. 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.

Create a New Repository and a Codespace

You can create a new repository with the Ocean SDK already installed and a new codespace by creating a repository from the dwave-examples template via the Use this template button and a new codespace via Code > Codespaces.

If the Ocean SDK is not installed in a repository, you can still install it by following the instructions on the Installing Ocean Tools page.

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.

  1. In a terminal, type dwave auth login --oob (as shown below) and press Enter:

    dave_auth_login_oob.png

    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.

    dwave_auth_login_oob_open_leap_dialog.png
  2. Click Open.
    If you are not currently logged into the Leap service, a new tab opens and displays the Leap login page. 
  3. Enter your account credentials and log in.
  4. Click Authorize on the Leap Request for Permission tab, which asks for permission to access your Leap Solver API token.
  5. In the Authorization Code field, an authorization code is displayed. Click the Copy icon that is displayed above the authorization code.
  6. Return to the terminal in Codespaces, paste the authorization code into the terminal at the prompt, and press Enter.
    dwave_auth_login_oob_auth_prompt.png
    A confirmation message displays, as shown below.
    dwave_auth_login_oob_auth_confirm1.png

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.

  1. In the terminal, type dwave config create --auto-token and press Enter.
  2. A message displays stating that a SAPI token was fetched from your Leap project and a configuration was saved.
    dwave_auth_login_oob_auth_confirm.png
    You can now run the Python code and access the D-Wave solvers.

For more detailed information, see Leap Support for IDEs.

Was this article helpful?
2 out of 2 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.