Skip to content

Commit

Permalink
Support Instantiation, Linting and GitHub CI (#1)
Browse files Browse the repository at this point in the history
* Instantiate backends

* Add tox and CI

* Update CI and README
  • Loading branch information
Sampreet authored Oct 14, 2024
1 parent 75a2bb8 commit 92e02f9
Show file tree
Hide file tree
Showing 29 changed files with 818 additions and 479 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/python-tox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: tox

on: [
push,
pull_request,
]

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [
ubuntu-latest,
macos-latest,
windows-latest,
]

steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- name: Install dependencies
run: pip install -r requirements.txt
- name: Install package
run: pip install -e .

test:

runs-on: ubuntu-latest
strategy:
matrix:
python: [
"3.10",
"3.12",
]

steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: "pip"
- name: Install tox
run: pip install tox
- name: Run tox
run: tox
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog

## 2027/08/09 - 00 - v0.0.7 - Update Callback
## 2024/10/14 - 00 - v0.0.8 - Instantiation and GitHub CI
* Instantiated backends and solvers with different numerical libraries:
* Added `context_manager` modules to `quantrl.backends` and `quantrl.solvers` packages.
* Added support for JIT-compilation in `quantrl.backends` package.
* Changed naming convention for GPU-based options as `gpu` from `cuda`.
* Added `tox`-based testing and continuous integration with GitHub workflows.
* Updated all modules with PEP-based code styling and added `pylintrc`.
* Updated `requirements.txt` and added version to `quantrl.__init__`.
* Replaced `setup.py` with `pyproject.toml`.
* Updated `docs` and `README`.

## 2024/08/09 - 00 - v0.0.7 - Update Callback
* Fixed issue with cache indexing in `quantrl.envs.base` module.
* Updated best reward callback in `quantrl.utils` module.
* Added `seaborn` to `requirements` and `setup`.
Expand Down
File renamed without changes.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# QuantRL: Quantum Control using Reinforcement Learning

![Latest Version](https://img.shields.io/badge/version-0.0.7-red?style=for-the-badge)
![Latest Version](https://img.shields.io/badge/version-0.0.8-red?style=for-the-badge)

> A library of modules to interface deterministic and stochastic quantum models for reinforcement learning.
Expand Down Expand Up @@ -30,7 +30,7 @@ The toolbox primarily relies on `gymnasium` (for single environments) and `stabl
All of its dependencies can be installed using:

```bash
conda install "numpy<2.0.0" scipy matplotlib tqdm gymnasium stable-baselines3
conda install "numpy<2.0.0" scipy matplotlib tqdm pillow pandas gymnasium stable-baselines3
```

Additionally, to avail the PyTorch or JAX backends, the latest version of these framework (for both CPU and GPU) should be installed (preferably in different `conda` environments) using in their official documentations: [PyTorch docs](https://pytorch.org/get-started/locally/) and [JAX docs](https://jax.readthedocs.io/en/latest/installation.html).
Expand All @@ -43,14 +43,16 @@ pip install torchdiffeq
or,

```bash
pip install jax
pip install diffrax
```

To install JAX with GPU support, use `jax[cuda12]`.

***Note: JAX-GPU support for Windows and MacOS is still limited but it runs well in WSL2.***

Finally, to install the latest version of `quantrl` locally, download the repository as `.zip` and extract the contents, or clone the repository.
Now, execute the following from *outside* the top-level directory, `ROOT_DIR`, inside which `setup.py` is located as:
Finally, to install the latest version of `quantrl`, execute:

```bash
pip install -e ROOT_DIR
```
pip install git+https://github.com/sampreet/quantrl.git
```
9 changes: 9 additions & 0 deletions docs/source/quantrl.backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ quantrl.backends.base module
:undoc-members:
:show-inheritance:

quantrl.backends.context_manager module
---------------------------------------

.. automodule:: quantrl.backends.context_manager
:members:
:private-members:
:undoc-members:
:show-inheritance:

quantrl.backends.jax module
---------------------------

Expand Down
9 changes: 9 additions & 0 deletions docs/source/quantrl.solvers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ quantrl.solvers.base module
:undoc-members:
:show-inheritance:

quantrl.backends.context_manager module
---------------------------------------

.. automodule:: quantrl.backends.context_manager
:members:
:private-members:
:undoc-members:
:show-inheritance:

quantrl.solvers.jax module
--------------------------

Expand Down
26 changes: 26 additions & 0 deletions pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[MESSAGES CONTROL]
disable=too-many-lines,
too-many-locals,
too-many-arguments,
too-many-statements,
too-few-public-methods,
too-many-public-methods,
too-many-instance-attributes,
too-many-positional-arguments,
line-too-long, # no bounded lines
redefined-builtin, # catches __name__
duplicate-code, # catches __init__
unused-argument, # catches Gym.Env methods
import-outside-toplevel, # for numerical libraries
not-callable, # catches JAX JIT functions
fixme

[BASIC]
attr-naming-style=any
variable-naming-style=any
argument-naming-style=any
const-naming-style=UPPER_CASE
method-naming-style=any
function-naming-style=any
class-naming-style=PascalCase
class-attribute-naming-style=snake_case
87 changes: 87 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[build-system]
requires = ["cython", "setuptools>=61", "wheel"]
build-backend = "setuptools.build_meta"

[project]
dynamic = ["version"]
name = "quantrl"
authors = [
{name = "Sampreet Kalita", email = "9553215+Sampreet@users.noreply.github.com"},
]
maintainers = [
{name = "Sampreet Kalita", email = "9553215+Sampreet@users.noreply.github.com"},
]
description = "Quantum Control with Reinforcement Learning"
keywords = [
"quantum",
"toolbox",
"reinforcement learning",
"python3",
]
readme = "README.md"
license = {file = "LICENSE"}
requires-python = ">=3.10"
dependencies = [
"numpy<2.0.0",
"scipy",
"matplotlib",
"tqdm",
"pillow",
"pandas",
"gymnasium",
"stable-baselines3",
]
classifiers = [
"Programming Language :: Python :: 3",
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering",
]

[project.optional-dependencies]
jax-cpu = [
"jax",
"diffrax",
]
jax-gpu = [
"jax[cuda12]",
"diffrax",
]
torch = [
"torch",
"torchvision",
"torchaudio",
"torchdiffeq",
]

[project.urls]
Homepage = "https://github.com/sampreet/quantrl"
Repository = "https://github.com/sampreet/quantrl"
Issues = "https://github.com/sampreet/quantrl/issues"
Changelog = "https://github.com/sampreet/quantrl/blob/master/CHANGELOG.md"

[tool.setuptools.packages.find]
include = ["quantrl"]
namespaces = false

[tool.setuptools.dynamic]
version = {attr = "quantrl.__version__"}

[tool.tox]
legacy_tox_ini = """
[tox]
requires =
tox>=4
virtualenv>=20
env_list =
lint
[testenv:lint]
description = run pylint under {base_python}
deps =
-r requirements_tox.txt
commands =
pylint quantrl
"""
2 changes: 2 additions & 0 deletions quantrl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"""Module to initialize QuantRL."""
__version__ = "0.0.8"
Loading

0 comments on commit 92e02f9

Please sign in to comment.