Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
amazon-braket-schemas
Advanced tools
Amazon Braket Python Schemas is an open source library that contains the schemas for Braket, including:
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__
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
"""
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
.
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.
This project is licensed under the Apache-2.0 License.
FAQs
An open source library that contains the schemas for Amazon Braket
We found that amazon-braket-schemas demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.