Skip to main content

An open source framework for interacting with D-Wave's Ocean library through Amazon Braket

Project description

Amazon Braket Ocean Plugin

Latest Version Supported Python Versions Build Status codecov Documentation Status Code Style: Black

The Amazon Braket Ocean Plugin is an open source library in Python that provides a framework that you can use to interact with Ocean tools on top of Amazon Braket.

Prerequisites

Before you begin working with the Amazon Braket Ocean Plugin, make sure that you've installed or configured the following prerequisites.

Python 3.7.2 or greater

Download and install Python 3.7.2 or greater from Python.org. If you are using Windows, choose Add Python to environment variables before you begin the installation.

Amazon Braket SDK

Make sure that your AWS account is onboarded to Amazon Braket, as per the instructions in the README.

Ocean tools

Download and install Ocean tools.

pip install dwave-ocean-sdk

Install the Amazon Braket Ocean Plugin

The Amazon Braket Ocean Plugin can be installed with pip as follows:

pip install amazon-braket-ocean-plugin

You can also install from source by cloning this repository and running a pip install command in the root directory of the repository:

git clone https://github.com/aws/amazon-braket-ocean-plugin-python.git
cd amazon-braket-ocean-plugin-python
pip install .

You can check your currently installed version of amazon-braket-ocean-plugin with pip show:

pip show amazon-braket-ocean-plugin

or alternatively from within Python:

>>> from braket import ocean_plugin
>>> ocean_plugin.__version__

Documentation

Detailed documentation, including the API reference, can be found on Read the Docs.

To generate the API Reference HTML in your local environment

First, you must have tox installed.

pip install tox

Then, you can run the following command with tox to generate the documentation:

tox -e docs

To view the generated documentation, open the following file in a browser: BRAKET_OCEAN_PLUGIN_ROOT/build/documentation/html/index.html

Usage

This package provides samplers which use Braket solvers. These samplers extend abstract base classes provided in Ocean's dimod and thus have the same interfaces as other samplers in Ocean.

BraketSampler is a structured sampler that uses Braket-formatted parameters and properties. For example, instead of answer_mode, which is used for D-Wave QPU samplers, Braket uses resultFormat instead. Linked is a sample example of solving the minimum vertex cover problem using BraketSampler.

BraketDWaveSampler is a structured sampler that uses D-Wave-formatted parameters and properties. It is interchangeable with D-Wave's DWaveSampler. Linked is the same example as above of solving the minimum vertex cover problem. Only the parameter inputs to the solver have been changed to be D-Wave formatted (e.g. answer_mode instead of resultFormat).

These usage examples can be found as python scripts in the BRAKET_OCEAN_PLUGIN_ROOT/examples/ folder.

Debugging Logs

Tasks sent to QPUs don't always complete right away. To view task status, you can enable debugging logs. An example of how to enable these logs is included in the repo: BRAKET_OCEAN_PLUGIN_ROOT/examples/debug_*. These examples enable task logging so that status updates are continuously printed to terminal after a quantum task is executed. The logs can also be configured to save to a file or output to another stream. You can use the debugging example to get information on the tasks you submit, such as the current status, so that you know when your task completes.

Install Additional Packages for Testing

Make sure to install test dependencies first:

pip install -e "amazon-braket-ocean-plugin-python[test]"

Unit Tests

To run the unit tests:

tox -e unit-tests

You can also pass in various pytest arguments to run selected tests:

tox -e unit-tests -- your-arguments

For more information, please see pytest usage.

To run linters and doc generators and unit tests:

tox

Integration Tests

Set the AWS_PROFILE, as instructed in the amazon-braket-sdk-python README.

export AWS_PROFILE=YOUR_PROFILE_NAME

Running the integration tests will create an S3 bucket in the same account as the AWS_PROFILE with the following naming convention amazon-braket-ocean-plugin-integ-tests-{account_id}.

Run the tests:

tox -e integ-tests

As with unit tests, you can also pass in various pytest arguments:

tox -e integ-tests -- your-arguments

License

This project is licensed under the Apache-2.0 License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amazon-braket-ocean-plugin-1.0.9.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

amazon_braket_ocean_plugin-1.0.9-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file amazon-braket-ocean-plugin-1.0.9.tar.gz.

File metadata

  • Download URL: amazon-braket-ocean-plugin-1.0.9.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for amazon-braket-ocean-plugin-1.0.9.tar.gz
Algorithm Hash digest
SHA256 dd6923d8b654775f3b896c8edf97295179ef68cc9ee19bfa47e746c456f4e6e8
MD5 faadbdb7a0d2ce89f76d0ab6209872b5
BLAKE2b-256 411db22ea5d6784bd28f44eb84da6f97458c32c590fd71c74f35af28ed81a4f5

See more details on using hashes here.

File details

Details for the file amazon_braket_ocean_plugin-1.0.9-py3-none-any.whl.

File metadata

  • Download URL: amazon_braket_ocean_plugin-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for amazon_braket_ocean_plugin-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b76f9ecfdc1260560be1660a1b9580a7dd44d2bd044493ab7b11679a22bf9f9b
MD5 65be3e5f27d9f0d488b811fd7ddc46ab
BLAKE2b-256 e50c65ae5104217f9f493dd9228b4213017c659997f0b8b0b759bb27601ad47b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page