-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge current AutoQASM code from Braket SDK repo
Merging the current version of the feature/autoqasm branch as of commit amazon-braket/amazon-braket-sdk-python@d62e288, with mechanical changes to module namespaces, file paths, and packaging. Co-authored-by: Tim (Yi-Ting) Chen <[email protected]> Co-authored-by: Lauren Capelluto <[email protected]> Co-authored-by: Aaron Berdy <[email protected]> Co-authored-by: Jean-Christophe Jaskula <[email protected]> Co-authored-by: Yunong Shi <[email protected]> Co-authored-by: Cody Wang <[email protected]>
- Loading branch information
Showing
98 changed files
with
17,541 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[run] | ||
parallel = True | ||
branch = True | ||
source = | ||
src | ||
omit = | ||
**/braket/ir/* | ||
**/braket/device_schema/* | ||
**/braket/schema_common/* | ||
**/braket/task_result/* | ||
**/braket/simulator/* | ||
*/site-packages/braket/* | ||
|
||
[paths] | ||
source = | ||
src | ||
*/site-packages/braket | ||
|
||
[report] | ||
show_missing = True | ||
ignore_errors = True | ||
exclude_lines = | ||
# Have to re-enable the standard pragma | ||
pragma: no cover | ||
|
||
# Skipping import testing | ||
from importlib.metadata import entry_points | ||
|
||
# Don't complain if tests don't hit defensive assertion code: | ||
raise NotImplementedError | ||
|
||
# Avoid situation where system version causes coverage issues | ||
if sys.version_info.minor == 9: | ||
|
||
[html] | ||
directory = build/coverage | ||
|
||
[xml] | ||
output = build/coverage/coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
if [ -f .pre-commit-config.yaml ]; then | ||
echo 'pre-commit configuration detected, but `pre-commit install` was never run' 1>&2 | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
name: Bug report | ||
about: File a report to help us reproduce and fix the problem | ||
title: '' | ||
labels: 'bug' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To reproduce** | ||
A clear, step-by-step set of instructions to reproduce the bug. | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots or logs** | ||
If applicable, add screenshots or logs to help explain your problem. | ||
|
||
**System information** | ||
A description of your system. Please provide: | ||
- **Amazon Braket Python SDK version**: | ||
- **Amazon Braket Python Schemas version**: | ||
- **Amazon Braket Python Default Simulator version**: | ||
- **Python version**: | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
blank_issues_enabled: false | ||
contact_links: | ||
- name: Ask a question | ||
url: https://forums.aws.amazon.com/tags/braket | ||
about: Use AWS Developer Forums to ask and answer questions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: Documentation request | ||
about: Request improved documentation | ||
title: '' | ||
labels: 'documentation' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**What did you find confusing? Please describe.** | ||
A clear and concise description of what you found confusing. Ex. I tried to [...] but I didn't understand how to [...] | ||
|
||
**Describe how documentation can be improved** | ||
A clear and concise description of where documentation was lacking and how it can be improved. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the documentation request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest new functionality for this library | ||
title: '' | ||
labels: 'feature' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the feature you'd like** | ||
A clear and concise description of the functionality you want. | ||
|
||
**How would this feature be used? Please describe.** | ||
A clear and concise description of the use case for this feature. Please provide an example, if possible. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Set update schedule for GitHub Actions | ||
|
||
version: 2 | ||
updates: | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
# Check for updates to GitHub Actions every week | ||
interval: "weekly" | ||
commit-message: | ||
prefix: infra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
*Issue #, if available:* | ||
|
||
*Description of changes:* | ||
|
||
*Testing done:* | ||
|
||
## Merge Checklist | ||
|
||
_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request._ | ||
|
||
#### General | ||
|
||
- [ ] I have read the [CONTRIBUTING](https://github.com/amazon-braket/amazon-braket-sdk-python/blob/main/CONTRIBUTING.md) doc | ||
- [ ] I used the commit message format described in [CONTRIBUTING](https://github.com/amazon-braket/amazon-braket-sdk-python/blob/main/CONTRIBUTING.md#commit-your-change) | ||
- [ ] I have updated any necessary documentation, including [READMEs](https://github.com/amazon-braket/amazon-braket-sdk-python/blob/main/README.md) and [API docs](https://github.com/amazon-braket/amazon-braket-sdk-python/blob/main/CONTRIBUTING.md#documentation-guidelines) (if appropriate) | ||
|
||
#### Tests | ||
|
||
- [ ] I have added tests that prove my fix is effective or that my feature works (if appropriate) | ||
- [ ] I have checked that my tests are not configured for a specific region or account (if appropriate) | ||
|
||
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
|
||
import fileinput | ||
from pathlib import Path | ||
|
||
# Here we replace the `amazon-braket-sdk` dependency to point to the file system; otherwise | ||
# pip will install them separately, allowing it to override the version of | ||
# any mutual dependencies with the sdk. By pointing to the file system, pip will be | ||
# forced to reconcile the dependencies in setup.py with the dependencies of the sdk, | ||
# and raise an error if there are conflicts. While we can't do this for every upstream | ||
# dependency, we can do this for the ones we own to make sure that when the sdk updates | ||
# its dependencies, these upstream github repos will not be impacted. | ||
|
||
package = "amazon-braket-sdk" | ||
path = Path.cwd().parent.resolve() | ||
|
||
for line in fileinput.input("setup.py", inplace=True): | ||
# Update the amazon-braket-sdk dependency in setup.py to use the local path. This | ||
# would help catch conflicts during the installation process. | ||
replaced_line = ( | ||
line if package not in line else f'"{package} @ file://{path}/{package}-python",\n' | ||
) | ||
print(replaced_line, end="") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Check code format | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- feature/** | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
check-code-format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: Set up Python | ||
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 | ||
with: | ||
python-version: '3.9' | ||
- name: Install dependencies | ||
run: | | ||
pip install tox | ||
- name: Run code format checks | ||
run: | | ||
tox -e linters_check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Code Freeze | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
FROZEN: ${{ vars.FROZEN }} | ||
UNFROZEN_PREFIX: ${{ vars.UNFROZEN_PREFIX }} | ||
|
||
jobs: | ||
check-pr-frozen-status: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fetch PR data and check if merge allowed | ||
if: env.FROZEN == 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
PR_DATA=$(curl -s \ | ||
-H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}) | ||
BRANCH_NAME=$(echo $PR_DATA | jq .head.ref -r) | ||
PR_TITLE=$(echo $PR_DATA | jq .title -r) | ||
echo $BRANCH_NAME | ||
echo $PR_TITLE | ||
# if it's not a critical fix | ||
if ! [[ "$PR_TITLE" == fix\(critical\):* ]]; then | ||
# and there's an unfrozen prefix | ||
if ! [[ -z $UNFROZEN_PREFIX ]]; then | ||
# check if the branch matches unfrozen prefix | ||
if [[ "$BRANCH_NAME" != $UNFROZEN_PREFIX* ]]; then | ||
echo "Error: You can only merge from branches that start with '$UNFROZEN_PREFIX', or PRs titled with prefix 'fix(critical): '." | ||
exit 1 | ||
fi | ||
# repo is fully frozen | ||
else | ||
echo "Error: You can only merge PRs titled with prefix 'fix(critical): '." | ||
exit 1 | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Publish distribution to PyPI | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build-and-publish: | ||
name: Build and publish distribution to PyPi | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: Set up Python | ||
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 | ||
with: | ||
python-version: '3.x' | ||
- name: Install wheel | ||
run: python -m pip install --user --upgrade wheel | ||
- name: Install twine | ||
run: python -m pip install --user --upgrade twine | ||
- name: Install setuptools | ||
run: python -m pip install --user --upgrade setuptools | ||
- name: Build a binary wheel and a source tarball | ||
run: python setup.py sdist bdist_wheel | ||
- name: Publish distribution to PyPI | ||
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # release/v1 | ||
with: | ||
password: ${{ secrets.pypi_token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Python package | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
- feature/** | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: ["3.9", "3.10", "3.11"] | ||
|
||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
pip install tox | ||
- name: Run unit tests | ||
run: | | ||
tox -e unit-tests | ||
- name: Run AutoQASM example notebooks | ||
run: | | ||
pip install -e . | ||
pip install notebook matplotlib | ||
jupyter nbconvert --to html --execute --ExecutePreprocessor.kernel_name=python3 ./examples/1_Getting_started_with_AutoQASM.ipynb | ||
jupyter nbconvert --to html --execute --ExecutePreprocessor.kernel_name=python3 ./examples/2_Expressing_classical_control_flow.ipynb | ||
jupyter nbconvert --to html --execute --ExecutePreprocessor.kernel_name=python3 ./examples/3_1_Iterative_phase_estimation.ipynb | ||
jupyter nbconvert --to html --execute --ExecutePreprocessor.kernel_name=python3 ./examples/3_2_magic_state_distillation.ipynb | ||
- name: Upload coverage report to Codecov | ||
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
if: ${{ strategy.job-index }} == 0 |
Oops, something went wrong.