Skip to content

Commit

Permalink
documentation: remove private beta instructions, add PR template, add… (
Browse files Browse the repository at this point in the history
amazon-braket#36)

* documentation: remove private beta instructions, add PR template, add to CONTRIBUTING.md

* change: version bump
  • Loading branch information
avawang1 authored Aug 12, 2020
1 parent 2d761a5 commit 77a0e8b
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 46 deletions.
22 changes: 22 additions & 0 deletions .github/pull_request_template.md
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/aws/amazon-braket-default-simulator-python/blob/main/CONTRIBUTING.md) doc
- [ ] I used the commit message format described in [CONTRIBUTING](https://github.com/aws/amazon-braket-default-simulator-python/blob/main/CONTRIBUTING.md#commit-your-change)
- [ ] I have updated any necessary documentation, including [READMEs](https://github.com/aws/amazon-braket-default-simulator-python/blob/main/README.md) and [API docs](https://github.com/aws/amazon-braket-default-simulator-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.
189 changes: 165 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,196 @@ Please read through this document before submitting any issues or pull requests
information to effectively respond to your bug report or contribution.


## Reporting Bugs/Feature Requests
## Table of Contents

* [Report Bugs/Feature Requests](#report-bugsfeature-requests)
* [Contribute via Pull Requests (PRs)](#contribute-via-pull-requests-prs)
* [Pull Down the Code](#pull-down-the-code)
* [Run the Unit Tests](#run-the-unit-tests)
* [Run the Performance Tests](#run-the-performance-tests)
* [Make and Test Your Change](#make-and-test-your-change)
* [Commit Your Change](#commit-your-change)
* [Send a Pull Request](#send-a-pull-request)
* [Documentation Guidelines](#documentation-guidelines)
* [API References (docstrings)](#api-references-docstrings)
* [Build and Test Documentation](#build-and-test-documentation)
* [Find Contributions to Work On](#find-contributions-to-work-on)
* [Code of Conduct](#code-of-conduct)
* [Security Issue Notifications](#security-issue-notifications)
* [Licensing](#licensing)

## Report Bugs/Feature Requests

We welcome you to use the GitHub issue tracker to report bugs or suggest features.

When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already
When filing an issue, please check [existing open](https://github.com/aws/amazon-braket-default-simulator-python/issues) and [recently closed](https://github.com/aws/amazon-braket-default-simulator-python/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20) issues to make sure somebody else hasn't already
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:

* A reproducible test case or series of steps
* The version of our code being used
* Any modifications you've made relevant to the bug
* Anything unusual about your environment or deployment
* A reproducible test case or series of steps.
* The version of our code being used.
* Any modifications you've made relevant to the bug.
* A description of your environment or deployment.


## Contributing via Pull Requests
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
## Contribute via Pull Requests (PRs)

1. You are working against the latest source on the *master* branch.
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
Contributions via pull requests are much appreciated.

To send us a pull request, please:
Before sending us a pull request, please ensure that:

1. Fork the repository.
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
3. Ensure local tests pass.
4. Commit to your fork using clear commit messages.
5. Send us a pull request, answering any default questions in the pull request interface.
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
* You are working against the latest source on the *main* branch.
* You check the existing open and recently merged pull requests to make sure someone else hasn't already addressed the problem.
* You open an issue to discuss any significant work - we would hate for your time to be wasted.

GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).

### Pull Down the Code

## Finding contributions to work on
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
1. If you do not already have one, create a GitHub account by following the prompts at [Join Github](https://github.com/join).
1. Create a fork of this repository on GitHub. You should end up with a fork at `https://github.com/<username>/amazon-braket-default-simulator-python`.
1. Follow the instructions at [Fork a Repo](https://help.github.com/en/articles/fork-a-repo) to fork a GitHub repository.
1. Clone your fork of the repository: `git clone https://github.com/<username>/amazon-braket-default-simulator-python` where `<username>` is your github username.


### Run the Unit Tests

1. Install tox using `pip install tox`
1. Install coverage using `pip install .[test]`
1. cd into the amazon-braket-default-simulator-python folder: `cd amazon-braket-default-simulator-python` or `cd /environment/amazon-braket-default-simulator-python`
1. Run the following tox command and verify that all unit tests pass: `tox -e unit-tests`

You can also pass in various pytest arguments `tox -e unit-tests -- your-arguments` to run selected tests. For more information, please see [pytest usage](https://docs.pytest.org/en/stable/usage.html).


### Run the Performance Tests

To run the performance tests:
```bash
tox -e performance-tests
```
These tests will compare the performance of a series of simulator executions for your changes against the latest commit on the main branch.
*Note*: The execution times for the performance tests are affected by the other processes running on the system.


### Make and Test Your Change

1. Create a new git branch:
```shell
git checkout -b my-fix-branch main
```
1. Make your changes, **including unit tests** and, if appropriate, integration tests.
1. Include unit tests when you contribute new features or make bug fixes, as they help to:
1. Prove that your code works correctly.
1. Guard against future breaking changes to lower the maintenance cost.
1. Please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
1. Run `tox`, to run all the unit tests, linters, and documentation creation, and verify that all checks and tests pass.
1. If your changes include documentation changes, please see the [Documentation Guidelines](#documentation-guidelines).


### Commit Your Change

We use commit messages to update the project version number and generate changelog entries, so it's important for them to follow the right format. Valid commit messages include a prefix, separated from the rest of the message by a colon and a space. Here are a few examples:
```
feature: support new parameter for `xyz`
fix: fix flake8 errors
documentation: add documentation for `xyz`
```
Valid prefixes are listed in the table below.
| Prefix | Use for... |
|----------------:|:-----------------------------------------------------------------------------------------------|
| `breaking` | Incompatible API changes. |
| `deprecation` | Deprecating an existing API or feature, or removing something that was previously deprecated. |
| `feature` | Adding a new feature. |
| `fix` | Bug fixes. |
| `change` | Any other code change. |
| `documentation` | Documentation changes. |
Some of the prefixes allow abbreviation ; `break`, `feat`, `depr`, and `doc` are all valid. If you omit a prefix, the commit will be treated as a `change`.
For the rest of the message, use imperative style and keep things concise but informative. See [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/) for guidance.
### Send a Pull Request
GitHub provides additional documentation on [Creating a Pull Request](https://help.github.com/articles/creating-a-pull-request/).
Please remember to:
* Use commit messages (and PR titles) that follow the guidelines under [Commit Your Change](#commit-your-change).
* Send us a pull request, answering any default questions in the pull request interface.
* Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
## Documentation Guidelines
We use reStructuredText (RST) for most of our documentation. For a quick primer on the syntax,
see [the Sphinx documentation](https://www.sphinx-doc.org/en/main/usage/restructuredtext/basics.html).
In this repository, we the docstrings create the API reference found on readthedocs.
Here are some general guidelines to follow when writing either kind of documentation:
* Use present tense.
* 👍 "The device has this property..."
* 👎 "The device will have this property."
* When referring to an AWS product, use its full name in the first invocation.
(This applies only to prose; use what makes sense when it comes to writing code, etc.)
* 👍 "Amazon S3"
* 👎 "s3"
* Provide links to other ReadTheDocs pages, AWS documentation, etc. when helpful.
Try to not duplicate documentation when you can reference it instead.
* Use meaningful text in a link.
### API References (docstrings)
The API references are generated from docstrings.
A docstring is the comment in the source code that describes a module, class, function, or variable.
```python
def foo():
"""This comment is a docstring for the function foo."""
```
We use [Google-style docstrings](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html).
There should be a docstring for every public module, class, and function.
For functions, make sure your docstring covers all of the arguments, exceptions, and any other relevant information.
When possible, link to classes and functions, e.g. use ":class:~\`braket.aws.AwsSession\`" over just "AwsSession."
If a parameter of a function has a default value, please note what the default is.
If that default value is `None`, it can also be helpful to explain what happens when the parameter is `None`.
If `**kwargs` is part of the function signature, link to the parent class(es) or method(s) so that the reader knows where to find the available parameters.
### Build and Test Documentation
To build the Sphinx docs, run the following command in the root repo directory:
```shell
tox -e docs
```
You can then find the generated HTML files in `build/documentation/html`.
## Find Contributions to Work On
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws/amazon-braket-default-simulator-python/labels/help%20wanted) issues is a great place to start.
## Code of Conduct
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
[email protected] with any additional questions or comments.
## Security issue notifications
## Security Issue Notifications
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
## Licensing
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
See the [LICENSE](https://github.com/aws/amazon-braket-default-simulator-python/blob/main/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.

We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.
29 changes: 12 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
**This prerelease documentation is confidential and is provided under the terms of your nondisclosure agreement with
Amazon Web Services (AWS) or other agreement governing your receipt of AWS confidential information.**
## Amazon Braket Default Simulator

The Amazon Braket Default Simulator is a Python open source library that provides an implementation of a quantum simulator
that you can run locally. You can use the simulator to test quantum tasks that you construct for the [Amazon Braket SDK](https://github.com/aws/braket-python-sdk)
that you can run locally. You can use the simulator to test quantum tasks that you construct for the [Amazon Braket SDK](https://github.com/aws/amazon-braket-sdk-python)
before you submit them to the Amazon Braket service for execution.

## Setting up Amazon Braket Default Simulator Python
You must have the [Amazon Braket SDK](https://github.com/aws/braket-python-sdk) installed before you can use the local simulator.
Follow the instructions in the [README](https://github.com/aws/braket-python-sdk/blob/main/README.md) for setup.
You must have the [Amazon Braket SDK](https://github.com/aws/amazon-braket-sdk-python) installed to use the local simulator.
Follow the instructions in the [README](https://github.com/aws/amazon-braket-sdk-python/blob/main/README.md) for setup.

**Checking the version of the DefaultSimulator**

You can check your currently installed version of `amazon-braket-default-simulator-python` with `pip show`:
You can check your currently installed version of `amazon-braket-default-simulator` with `pip show`:

```bash
pip show amazon-braket-default-simulator-python
pip show amazon-braket-default-simulator
```

or alternatively from within Python:
Expand All @@ -26,7 +25,7 @@ or alternatively from within Python:

## Usage
The quantum simulator implementation `DefaultSimulator` plugs into the `LocalSimulator` interface in
[Amazon Braket SDK](https://github.com/aws/braket-python-sdk) using the `backend` value as `"default"`.
[Amazon Braket SDK](https://github.com/aws/amazon-braket-sdk-python) using the `backend` value as `"default"`.

**Executing a circuit using the DefaultSimulator**
```python
Expand All @@ -41,17 +40,13 @@ print(device.run(bell, shots=100).result().measurement_counts)

## Documentation

To view the documentation for the simulator, either download the .zip file or build it in your local environment.
**To generate the API Reference HTML in your local environment**

**To download the .zip file**
First, install tox:

Use the following command to download the .zip file
```bash
aws s3 cp s3://braket-external-assets-prod-us-west-2/sdk-docs/amazon-braket-default-simulator-documentation.zip amazon-braket-default-simulator-documentation.zip
pip install tox
```
Then extract the `amazon-braket-default-simulator-documentation.zip` file to your local environment. After you extract the file, open the index.html file.

**To generate the API Reference HTML in your local environment**

To generate the HTML, first change directories (`cd`) to position the cursor in the `amazon-braket-default-simulator-python` directory. Then, run the following command to generate the HTML documentation files:

Expand Down Expand Up @@ -83,9 +78,9 @@ These tests will compare the performance of a series of simulator executions for
*Note*: The execution times for the performance tests are affected by the other processes running on the system.
In order to get stable results, stop other applications when running these tests.

To run an individual test:
To run selected tests based on a key word in the test name:
```bash
tox -- -k 'your_test'
tox -- -k 'keyword'
```


Expand Down
2 changes: 1 addition & 1 deletion src/braket/default_simulator/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.4.0"
__version__ = "1.0.0"
8 changes: 4 additions & 4 deletions test/performance/compare_performance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ HAS_UNCOMMITTED_CHANGES="$(git status --porcelain)"
rm -rf "$REPOSITORY_ROOT/test/.benchmarks"
# Stash uncommitted changes (if any)
if [ -n "$HAS_UNCOMMITTED_CHANGES" ]; then git stash -u; fi
git checkout master
# Execute performance tests against the latest commit on the master branch
git checkout main
# Execute performance tests against the latest commit on the main branch
pytest --benchmark-autosave --benchmark-only --benchmark-timer='time.process_time' --benchmark-warmup='on' --benchmark-warmup-iterations=100 performance
# Stash the performance test execution results and switch back to the working branch
git stash -u && git checkout $WORKING_BRANCH
# Retrieve the stashed performance test execution results for the master branch (to compare against)
# Retrieve the stashed performance test execution results for the main branch (to compare against)
git stash pop
# Retrieve the uncommitted changes which had been stashed (if any)
if [ -n "$HAS_UNCOMMITTED_CHANGES" ]; then git stash pop; fi
# Execute the performance tests and compare the results against the master branch.
# Execute the performance tests and compare the results against the main branch.
# Fails if there >= 5% increase in the minimum execution time of any test
pytest --benchmark-autosave --benchmark-only --benchmark-timer='time.process_time' --benchmark-warmup='on' --benchmark-warmup-iterations=100 --benchmark-compare --benchmark-compare-fail=min:5% performance
# Cleanup benchmark metadata
Expand Down

0 comments on commit 77a0e8b

Please sign in to comment.