Skip to main content

An open source library that contains the schemas for Amazon Braket

Project description

Amazon Braket Python Schemas

Latest Version Supported Python Versions Build status codecov Documentation Status

Amazon Braket Python Schemas is an open source library that contains the schemas for Braket, including:

  • intermediate representations (IR) for Amazon Braket quantum tasks and offers serialization and deserialization of those IR payloads. Think of the IR as the contract between the Amazon Braket SDK and Amazon Braket API for quantum programs.
  • schemas for the S3 results of each quantum task
  • schemas for the device capabilities of each device

Installation

Prerequisites

  • Python 3.11+

Steps

The preferred way to get Amazon Braket Python Schemas is by installing the Amazon Braket Python SDK, which will pull in the schemas. Follow the instructions in the README for setup.

However, if you only want to use the schemas, it can be installed on its own as follows:

pip install amazon-braket-schemas

You can 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/amazon-braket/amazon-braket-schemas-python.git
cd amazon-braket-schemas-python
pip install .

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

pip show amazon-braket-schemas

or alternatively from within Python:

>>> import braket._schemas as braket_schemas
>>> braket_schemas.__version__

Usage

OpenQASM (Open Quantum Assembly Language) is one type of IR. See below for its usage.

Serializing python structures

from braket.ir.openqasm import Program as OpenQASMProgram

program = OpenQASMProgram(source="OPENQASM 3.0; cnot $0, $1;")
print(program.json(indent=2))

"""
{
  "braketSchemaHeader": {
    "name": "braket.ir.openqasm.program",
    "version": "1"
  },
  "source": "OPENQASM 3.0; cnot $0, $1;",
  "inputs": null
}
"""

Deserializing into python structures

from braket.ir.openqasm import Program as OpenQASMProgram

openqasm_string = """
{
  "braketSchemaHeader": {
    "name": "braket.ir.openqasm.program",
    "version": "1"
  },
  "source": "OPENQASM 3.0; cnot $0, $1;"
}"""

program = OpenQASMProgram.parse_raw(openqasm_string)
print(program)

"""
braketSchemaHeader=BraketSchemaHeader(name='braket.ir.openqasm.program', version='1') source='OPENQASM 3.0; cnot $0, $1;' inputs=None
"""

Documentation

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

You can also generate the docs from source. First, install tox:

pip install tox

To build the Sphinx docs, run the following command in the root repo directory:

tox -e docs

You can then find the generated HTML files in build/documentation/html.

Testing

Make sure to install test dependencies first:

pip install -e "amazon-braket-schemas-python[test]"

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

To run linters and doc generators and unit tests:

tox

For more information, please see pytest usage.

License

This project is licensed under the Apache-2.0 License.

Project details


Release history Release notifications | RSS feed

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_schemas-1.29.2.tar.gz (59.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amazon_braket_schemas-1.29.2-py3-none-any.whl (152.3 kB view details)

Uploaded Python 3

File details

Details for the file amazon_braket_schemas-1.29.2.tar.gz.

File metadata

  • Download URL: amazon_braket_schemas-1.29.2.tar.gz
  • Upload date:
  • Size: 59.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for amazon_braket_schemas-1.29.2.tar.gz
Algorithm Hash digest
SHA256 71089b857a388bc7d9dab6dfb8c7748f378d130a46cf9f4614b67ebb5795ddf7
MD5 64d5d2a8a6a02bafb60f0c75c35a92f7
BLAKE2b-256 0d2cd2ffe82fbf044dfdee5366f0c357663e6aab55f61dac245d4e6878484d9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for amazon_braket_schemas-1.29.2.tar.gz:

Publisher: publish-to-pypi.yml on amazon-braket/amazon-braket-schemas-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file amazon_braket_schemas-1.29.2-py3-none-any.whl.

File metadata

File hashes

Hashes for amazon_braket_schemas-1.29.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a34e34f9d0496d50a7e723a4a806cb689b93ddd12405bea8037d976ee3e20653
MD5 9f97af844f00b2bd37c5d905b5020acf
BLAKE2b-256 d120acf992b9df08a6b2a0b1b8b96b78a2338b9d658cfd81e1e556c13e681dd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for amazon_braket_schemas-1.29.2-py3-none-any.whl:

Publisher: publish-to-pypi.yml on amazon-braket/amazon-braket-schemas-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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