Skip to content

Commit

Permalink
Merge pull request #46 from qutech-sd/gymnasium
Browse files Browse the repository at this point in the history
Gymnasium
  • Loading branch information
Willem-de-kok authored Jul 24, 2023
2 parents 4cc3e7a + e3f2662 commit 121bd97
Show file tree
Hide file tree
Showing 55 changed files with 1,874 additions and 1,438 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Compatibility

on: [push]

jobs:
pytest:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip
run: pip install --upgrade pip
- name: Install requirements
run: pip install .[test]
- name: Test with pytest
run: pytest tests
28 changes: 28 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: quality

on: push

jobs:
mypy:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v4
- name: Checkout
uses: actions/checkout@v3
- name: Install requirements
run: pip install mypy .
- name: Run mypy
run: mypy qgym

pylint:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v4
- name: Checkout
uses: actions/checkout@v3
- name: Install requirements
run: pip install pylint .
- name: Run pylint
run: pylint qgym
18 changes: 18 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: style

on: push

jobs:
black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
jupyter: true

isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: isort/isort-action@master
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Jetbrains
/.idea/

# venvs
/venv*/

# Python
/venv/
/build/
/dist/
/*.egg-info/
Expand All @@ -17,7 +19,7 @@

# Sphinx
/docs_build/
/docs_html/
/docs/

# Data/pictures
/images/
Expand Down
36 changes: 16 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,35 @@ Currently, we are not looking for any new contributors. We are happy to receive
# Developer notes
Below is a list of useful information for developers.

### Installing requirements
Make sure to install all requirements in your (preferably virtual) environment as follows.
The first command installs the latest versions of `pip`, `setuptools`, and `wheel`.
### Installing
Install `qgym` in editable mode (preferably virtual) environment as follows:

```commandline
pip install -U pip setuptools wheel
pip install -U -r requirements.txt
pip install --upgrade pip
pip install -e .[dev]
```
This will install the `qgym` package together with all tools needed for developing.

### Building and installing from source
### Building a wheel
To build a wheel from this source one can run the command below.
This will create a built wheel in a folder called `dist`.

_Make sure that `pip`, `setuptools`, `wheel` are up-to-date (see [above](#installing-requirements))_
This will create a built wheel in a folder called `dist`. Make sure that `pip`, `setuptools`, `wheel` are up-to-date.
```commandline
python setup.py bdist_wheel
```

### Building documentation
To build the documentation one should run the two commands below.
The HTML documentation will be placed in a folder called `docs_html`. This folder includes a file `index.html`, open this
in a browser to view the documentation.

To successfully build the documentation, one has to have the `qgym` packages installed in the environment.
To build the documentation one should run the command below.
```commandline
sphinx-apidoc -o docs_build -f -F -M -e -t docs --implicit-namespaces qgym
sphinx-build docs_build docs_html
python docs_files/make_docs.py
```
The HTML documentation will be placed in a folder called `docs`. This folder includes a
file `index.html`, open this in a browser to view the documentation.

### Developing jupyter notebooks
To launch a jupyter notebook environment ensure that the latest version of this library is installed,
including the developer dependencies.
To successfully build the documentation, one has to have the `qgym` packages installed.

_Make sure that `pip`, `setuptools`, `wheel` are up-to-date (see [above](#installing-requirements))_
### Developing jupyter notebooks
To launch a jupyter notebook environment ensure that the latest version of this library is installed.
If you are sure everything is up to date you can run:
```commandline
pip install -U .[dev]
jupyter notebook
Expand Down
24 changes: 24 additions & 0 deletions docs_files/make_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import shutil

import sphinx.cmd.build as sphinx_build
import sphinx.ext.apidoc as sphinx_apidoc

sphinx_apiddoc_args =[
"-o=docs_build",
"--templatedir=docs_files/templates",
"--force",
"--full",
"--module-first",
"--separate",
"--implicit-namespaces",
"qgym",
]

sphinx_build_args = ["docs_build","docs"]

sphinx_apidoc.main(sphinx_apiddoc_args)
sphinx_build.main(sphinx_build_args)

shutil.rmtree("docs_build")


File renamed without changes.
21 changes: 20 additions & 1 deletion docs/conf.py_t → docs_files/templates/conf.py_t
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import importlib

year = datetime.date.today().year
project = package_name
copyright = "2022, QuTech & TNO"
copyright = "2023, QuTech & TNO"
author = "QuTech & TNO"
version = importlib.import_module(package_name).__version__

Expand All @@ -31,6 +31,25 @@ extensions = [
napoleon_include_init_with_doc = True
napoleon_include_special_with_doc = True

# Make ArrayLike pretty. The `typehints_formatter`` must be a function with an
# annotation as first argument and a sphinx.config.Config as second argument. Returns
# the desired string or None for default behaviour.
try:
from typing import Optional

from numpy.typing import ArrayLike

def typehints_formatter(annotation, _):
if annotation == ArrayLike:
return ":py:const:`ArrayLike`"
if annotation == Optional[ArrayLike]:
return ":py:const:`Optional[ArrayLike]`"
return None

except ImportError:
pass


mathjax3_config = {
"tex2jax": {
"inlineMath": [["\\(", "\\)"]],
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion docs/root_doc.rst_t → docs_files/templates/root_doc.rst_t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

OpenQL Gym
===========
This reinforcement learning gym can be used to train agents on problems specific to the compilation of gate-based quantum software. It uses the concepts of OpenQL as basis for the provided environments.
This reinforcement learning gym can be used to train agents on problems specific to the
compilation of gate-based quantum software. It uses the concepts of OpenQL as basis for
the provided environments.

.. _introduction:

Expand Down
Loading

0 comments on commit 121bd97

Please sign in to comment.