Skip to content

Commit

Permalink
Add missing pieces for Qiskit project standards
Browse files Browse the repository at this point in the history
This commit adds the missing pieces from the repository to bring it more
inline with the rest of the projects under Qiskit. Mainly this means
adding templates for bugs, enhancements, and pull requests in addition
to adding a code of conduct and contributing guide. It also converts the
README file to be markdown instead of rst to be consistent with the rest
of Qiskit.
  • Loading branch information
mtreinish committed Mar 17, 2020
1 parent d308096 commit 3b51e87
Show file tree
Hide file tree
Showing 11 changed files with 282 additions and 106 deletions.
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Bug report
about: Create a bug report
labels: bug
---

<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **retworkx version**:
- **Python version**:
- **Rust version**:
- **Operating system**:

### What is the current behavior?


### What is the expected behavior?


### Steps to reproduce the problem


12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/ENHANCEMENT_REQUEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: Enhancement request
about: Suggest an improvement for this project
labels: 'type: enhancement'
---

<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues to confirm this idea does not exist. -->

### What is the expected enhancement?


9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!--
⚠️ Your pull request title should be short detailed and understandable for all.
⚠️ If your pull request fixes an open issue, please link to the issue.
- [ ] I ran rustfmt locally
- [ ] I have added the tests to cover my changes.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the CONTRIBUTING document.
-->
83 changes: 83 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: Contributor Covenant Code of Conduct
---

Our Pledge
==========

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our
project and our community a harassment-free experience for everyone,
regardless of age, body size, disability, ethnicity, gender identity and
expression, level of experience, nationality, personal appearance, race,
religion, or sexual identity and orientation.

Our Standards
=============

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual
attention or advances
- Trolling, insulting/derogatory comments, and personal or political
attacks
- Public or private harassment
- Publishing others\' private information, such as a physical or
electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in
a professional setting

Our Responsibilities
====================

Project maintainers are responsible for clarifying the standards of
acceptable behavior and are expected to take appropriate and fair
corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit,
or reject comments, commits, code, wiki edits, issues, and other
contributions that are not aligned to this Code of Conduct, or to ban
temporarily or permanently any contributor for other behaviors that they
deem inappropriate, threatening, offensive, or harmful.

Scope
=====

This Code of Conduct applies both within project spaces and in public
spaces when an individual is representing the project or its community.
Examples of representing a project or community include using an
official project e-mail address, posting via an official social media
account, or acting as an appointed representative at an online or
offline event. Representation of a project may be further defined and
clarified by project maintainers.

Enforcement
===========

Instances of abusive, harassing, or otherwise unacceptable behavior may
be reported by contacting the project team at <[email protected]>. The
project team will review and investigate all complaints, and will
respond in a way that it deems appropriate to the circumstances. The
project team is obligated to maintain confidentiality with regard to the
reporter of an incident. Further details of specific enforcement
policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in
good faith may face temporary or permanent repercussions as determined
by other members of the project\'s leadership.

Attribution
===========

This Code of Conduct is adapted from the Contributor
[Covenant](http://contributor-covenant.org),
[version](http://contributor-covenant.org/version/1/4/) 1.4.
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Contributing

First read the overall project contributing guidelines. These are all
included in the qiskit documentation:

https://qiskit.org/documentation/contributing_to_qiskit.html

## Contributing to retworkx

In addition to the general guidelines there are specific details for
contributing to retworkx, these are documented below.

### Tests

Once you've made a code change, it is important to verify that your change
does not break any existing tests and that any new tests that you've added
also run successfully. Before you open a new pull request for your change,
you'll want to run the test suite locally.

Right now tests can only be run manually by invoking python's unittest (or
a compatible runner) directly from a python environment with retworkx compiled
and installed. To do this you run:

```bash
python -m unittest discover .
```

from `./tests` in the repo (adjust `.` accordingly if you are running it from
another directoy). Note that you can **not** run the tests from the root of the
repo, this is because retworkx packaging shim will conflict with imports from
retworkx the installed version of retworkx (which contains the compiled
extension).

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "A python graph library implemented in Rust"
version = "0.3.2"
authors = ["Matthew Treinish <[email protected]>"]
license = "Apache-2.0"
readme = "README.rst"
readme = "README.md"
repository = "https://github.com/Qiskit/retworkx"
keywords = ["python", "graph"]

Expand Down
114 changes: 114 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# retworkx

[![License](https://img.shields.io/github/license/Qiskit/retworkx.svg?style=popout-square)](https://opensource.org/licenses/Apache-2.0)[![Build Status](https://img.shields.io/travis/com/Qiskit/retworkx/master.svg?style=popout-square)](https://travis-ci.com/Qiskit/retworkx)[![](https://img.shields.io/github/release/Qiskit/retworkx.svg?style=popout-square)](https://github.com/Qiskit/retworkx/releases)[![](https://img.shields.io/pypi/dm/retworkx.svg?style=popout-square)](https://pypi.org/project/retworkx/)

- You can see the full rendered docs at:
<https://retworkx.readthedocs.io/en/latest/index.html>

retworkx is a rust graph library interface to python3. For right now
it's scope is as a replacement for
[qiskit-terra](https://github.com/Qiskit/qiskit-terra)'s previous (and
current) networkx usage (hence the name). The scope might grow or change
over time, but to start it's just about building a DAG and operating on
it with the performance and safety that Rust provides.

## Installing retworkx

retworkx is published on pypi so on x86\_64, i686, ppc64le, and aarch64
Linux systems, x86\_64 on Mac OSX, and 32 and 64 bit Windows installing
is as simple as running:

```bash
pip install retworkx
```

This will install a precompiled version of retworkx into your python
environment.

However, if there are no precompiled binaries published for your system
you'll have to compile the code. The source package is also published on
pypi so you can also run the above command to install it. However, there
are 2 preconditions for this to work, first you need to have cargo/rustc
**nightly** in your PATH. You can use [rustup](https://rustup.rs/) to
make this step simpler. Secondly, you need to have `setuptools-rust`
installed in your python environment. This can can be done by simply
running:

```bash
pip install setuptools-rust
```

prior to running:

```bash
pip install retworkx
```

If you have rust nightly properly installed pip will compile retworkx
for your local system and it should run just as the prebuilt binaries
would.

## Building from source

The first step for building retworkx from source is to clone it locally
with:

```bash
git clone https://github.com/Qiskit/retworkx.git
```

retworkx uses [PyO3](https://github.com/pyo3/pyo3) and
[setuptools-rust](https://github.com/PyO3/setuptools-rust) to build the
python interface. Unfortunately, this means you need to use nightly rust
because PyO3 only works with nightly at this point. You can use
[rustup](https://rustup.rs/) to install rust nightly.

Once you have nightly rust and cargo installed you can easily install
retworkx into your python environment using pip. Once you have a local
clone of the repo, change your current working directory to the root of
the repo. To set the compiler for `retworkx` to nightly rust using
`rustup`, run the following from this directory:

```bash
rustup override set nightly
```

then, you can install retworkx into your python env with:
```bash
pip install .
```

Assuming your current working directory is still the root of the repo.
Otherwise you can run:
```bash
pip install $PATH_TO_REPO_ROOT
```

which will install it the same way. Then retworkx is installed inyour
local python environment. There are 2 things to note when doing this
though, first if you try to run python from the repo root using this
method it will not work as you expect. There is a name conflict in the
repo root because of the local python package shim used in building the
package. Simply run your python scripts or programs using retworkx
outside of the repo root. The second issue is that any local changes you
make to the rust code will not be reflected live in the python you'll
need to recompile the source by rerunning pip install to have any
changes reflected in your python environment.

## Using retworkx

Once you have retworkx installed you can use it by importing retworkx.
All the functions and the PyDAG class are off the root of the package.
For example, building a DAG and adding 2 nodes with an edge between them
would be:

```python
import retworkx

my_dag = retworkx.PyDAG()
# add_node(), add_child(), and add_parent() return the node index
# The sole argument here can be any python object
root_node = my_dag.add_node("MyRoot")
# The second and third arguments can be any python object
my_dag.add_child(root_node, "AChild", ["EdgeData"])
```
102 changes: 0 additions & 102 deletions README.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/source/README.rst

This file was deleted.

1 change: 1 addition & 0 deletions docs/source/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. mdinclude:: ../../README.md
Loading

0 comments on commit 3b51e87

Please sign in to comment.