Skip to content

Commit

Permalink
Switch tooling to hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
goerz committed Jun 1, 2024
1 parent e9bad00 commit c143c7e
Show file tree
Hide file tree
Showing 59 changed files with 3,006 additions and 2,889 deletions.
28 changes: 21 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
name: Docs

on: [push, ]
on:
push:
branches:
- master
- dev
- 'release-*'
tags:
- '*'
pull_request:
branches:
- master

jobs:

build_docs:
name: Build Sphinx docs
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:

- uses: actions/checkout@v2
Expand All @@ -16,14 +26,19 @@ jobs:
with:
python-version: 3.8

- name: Install zip-files
run: pip install zip-files

- name: Install apt packages
run: sudo apt-get install graphviz imagemagick pandoc pandoc-citeproc

- name: Install Tox and other Python package requirements
run: pip install tox zip-files
- name: Install Hatch
uses: pypa/hatch@install
with:
version: 1.11.1

- name: Generate HTML Documentation
run: tox -c tox-pyenv.ini -e docs
run: hatch run docs:build

- name: Get the version
id: get_version
Expand All @@ -45,7 +60,7 @@ jobs:
deploy_gh_pages:
name: Deploy documentation to gh-pages
if: always() && needs.build_docs.result == 'success' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
needs: [build_docs]
steps:

Expand Down Expand Up @@ -89,7 +104,6 @@ jobs:
- name: Set download links
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo "[pdf]: https://github.com/qucontrol/krotov/releases/download/${{ env.BRANCH_NAME }}/krotov-${{ env.BRANCH_NAME }}.pdf" > ./${{ env.BRANCH_NAME }}/_downloads
echo "[html]: https://github.com/qucontrol/krotov/releases/download/${{ env.BRANCH_NAME }}/krotov-${{ env.BRANCH_NAME }}.zip" >> ./${{ env.BRANCH_NAME }}/_downloads
- name: Remove artifact files
Expand Down
97 changes: 48 additions & 49 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
name: Tests

on: [push, pull_request]
on:
push:
branches:
- master
- dev
- 'release-*'
tags:
- '*'
pull_request:
branches:
- master


jobs:
Expand All @@ -9,84 +19,78 @@ jobs:
name: ${{ matrix.title }} (Python ${{ matrix.python }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
env:
tox: tox -c tox-pyenv.ini
default_tests: src tests README.rst docs/*.rst
strategy:
fail-fast: false
matrix:
include:
- title: Codestyle and Main Tests
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: |
$tox -e run-blackcheck,run-isortcheck
$tox -e py38-test -- $default_tests
hatch run lint:black-check
hatch run lint:isort-check
hatch run cov -- $default_tests
coverage: true
- title: Oldest supported Python
os: ubuntu-18.04
python: 3.6
commands: $tox -e py36-test -- $default_tests
os: ubuntu-22.04
python: 3.7
commands: hatch -e py37 run test -- $default_tests
coverage: false
- title: QuTiP master
os: ubuntu-18.04
python: 3.8
commands: $tox -e py38qtm-test -- $default_tests
continue-on-error: true # experimental
coverage: false
- title: Windows / Conda
- title: Windows
os: windows-latest
python: 3.6
commands: tox -c tox-conda.ini -e py36-test -- src tests README.rst docs\notebooks\01_example_simple_state_to_state.ipynb docs\notebooks\05_example_transmon_xgate.ipynb
python: 3.8
commands: hatch run test -- src tests README.rst docs\notebooks\01_example_simple_state_to_state.ipynb docs\notebooks\05_example_transmon_xgate.ipynb
coverage: false
- title: MacOS
os: macos-latest
python: 3.8
commands: $tox -e py38-test -- $default_tests docs/notebooks/01_example_simple_state_to_state.ipynb
commands: hatch run cov -- $default_tests docs/notebooks/01_example_simple_state_to_state.ipynb
coverage: true
- title: Notebook 1 (State-to-State)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/01_example_simple_state_to_state.ipynb
commands: hatch run cov -- docs/notebooks/01_example_simple_state_to_state.ipynb
coverage: true
- title: Notebook 2 (RWA)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/02_example_lambda_system_rwa_complex_pulse.ipynb
commands: hatch run cov -- docs/notebooks/02_example_lambda_system_rwa_complex_pulse.ipynb
coverage: true
- title: Notebook 3 (Non-Hermitian)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/03_example_lambda_system_rwa_non_hermitian.ipynb
commands: hatch run cov -- docs/notebooks/03_example_lambda_system_rwa_non_hermitian.ipynb
coverage: true
- title: Notebook 4 (Density Matrix)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/04_example_dissipative_qubit_reset.ipynb
commands: hatch run cov -- docs/notebooks/04_example_dissipative_qubit_reset.ipynb
coverage: true
- title: Notebook 5 (Quantum Gate)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/05_example_transmon_xgate.ipynb
commands: hatch run cov -- docs/notebooks/05_example_transmon_xgate.ipynb
coverage: true
- title: Notebook 6 (3 States)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/06_example_3states.ipynb
commands: hatch run cov -- docs/notebooks/06_example_3states.ipynb
coverage: true
- title: Notebook 7 (Perfect Entanglers)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/07_example_PE.ipynb
commands: hatch run cov -- docs/notebooks/07_example_PE.ipynb
coverage: true
- title: Notebook 8 (Ensemble Optimization)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/08_example_ensemble.ipynb
commands: hatch run cov -- docs/notebooks/08_example_ensemble.ipynb
coverage: true
- title: Notebook 9 (NumPy)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/09_example_numpy.ipynb
commands: hatch run cov -- docs/notebooks/09_example_numpy.ipynb
coverage: true
steps:
- uses: actions/checkout@v2
Expand All @@ -100,15 +104,10 @@ jobs:
if: runner.os == 'Linux'
run: sudo apt-get install pandoc pandoc-citeproc liblapack-dev libblas-dev gfortran

- name: Install miniconda
if: runner.os == 'Windows'
uses: conda-incubator/setup-miniconda@v2
- name: Install Hatch
uses: pypa/hatch@install
with:
auto-update-conda: true
python-version: ${{ matrix.python }}

- name: Install Tox
run: pip install tox
version: 1.11.1

- name: Run Commands
run: ${{ matrix.commands }}
Expand All @@ -117,10 +116,10 @@ jobs:
if: matrix.coverage == true
shell: bash
run: |
runenv=$(echo "${{ matrix.python }}" | sed 's/\([2-3]\)\.\([0-9]\)/py\1\2-runcmd/')
$tox -e $runenv -- python -m coverage xml
hatch run -- python -m coverage xml
- uses: codecov/codecov-action@v1
- name: Upload coverage to Codecov
if: matrix.coverage == true
with:
verbose: false
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ repos:
language: script
- id: black
name: black
entry: ./scripts/pre-commit.py black
entry: hatch run lint:black-check --
types: [python]
language: script
language: system
- id: isort
name: isort
entry: ./scripts/pre-commit.py isort
entry: hatch run lint:isort-check --
types: [python]
language: script
language: system
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ disable=invalid-name,
no-else-return,
ungrouped-imports,
unnecessary-lambda,

non-ascii-name,


# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
52 changes: 16 additions & 36 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ In short, if you are not a member of the `qucontrol organization`_,
7. Push changes to the topic branch on *your* remote.
8. Make a pull request against the base master branch through the Github website of your fork.

The project uses tox_ for automated testing accross multiple versions of Python
The project uses hatch_ for automated testing accross multiple versions of Python
and for various development tasks such as linting and generating the
documentation. See :ref:`DevelopmentPrerequisites` for details.

Expand Down Expand Up @@ -103,7 +103,7 @@ in order to set up the ``tox.ini`` configuration file.
If you are a member of the `qucontrol organization`_, there is no need to fork
``krotov`` - you can directly pull and push to ``git@github.com:qucontrol/krotov.git``.

.. _tox: https://tox.readthedocs.io
.. _hatch: https://hatch.pypa.io/latest/

.. _Aaron Meurer's Git Workflow Notes: https://www.asmeurer.com/git-workflow/

Expand All @@ -117,33 +117,13 @@ Development Prerequisites
-------------------------

Contributing to the package's developments requires that you have Python 3.8
and tox_ installed. It is strongly recommended that you also have installations
of all other supported Python versions. The recommended way to install multiple
versions of Python at the same time is through pyenv_ (or pyenv-win_ on
Windows).

Alternatively, you may install conda_ (via the Anaconda_ or Miniconda_
distributions, or also through pyenv_). As ``conda`` can create environments
with any version of Python (independent of which Python version ``conda`` was
originally installed with), this alleviates the need for managing multiple
versions.
The advantage of using conda_ is that you may be able to avoid installing the
compilers necessary for Python extension packages. The disadvantage is that
environment creation is slower and the resulting environments are bigger, and
that you may run into occasional binary incompatibilities between conda packages.

.. warning::
If you want to use `conda`, you must use the ``tox-conda.ini`` configuration
file. That is, run all ``make`` comands as e.g.
``make TOXINI=tox-conda.ini test`` and ``tox`` commands as e.g.
``tox -c tox-conda.ini -e py38-test``. Alternatively,
make ``tox-conda.ini`` the default by copying it to ``tox.ini``.
and hatch_ installed (tested with Hatch 1.11). It is strongly recommended that
you also have installations of all other supported Python versions. The
recommended way to install multiple versions of Python at the same time is
through pyenv_ (or pyenv-win_ on Windows).

.. _pyenv: https://github.com/pyenv/pyenv
.. _pyenv-win: https://github.com/pyenv-win/pyenv-win
.. _conda: https://conda.io/docs/
.. _Anaconda: https://www.anaconda.com/distribution/
.. _Miniconda: https://conda.io/en/latest/miniconda.html
.. _QuTiP: http://qutip.org


Expand Down Expand Up @@ -264,7 +244,7 @@ to run the entire test suite, or

.. code-block:: shell
tox -e py38-test
hatch run test
if ``make`` is not available.

Expand Down Expand Up @@ -292,16 +272,16 @@ readability significantly.

Beyond :pep:`8`, this project adopts the `Black code style`_, with
``--skip-string-normalization --line-length 79``. You can
run ``make black-check`` or ``tox -e run-blackcheck`` to check adherence to the
code style, and ``make black`` or ``tox -e run-black`` to apply it.
run ``make black-check`` or ``hatch run lint:black-check`` to check adherence to the
code style, and ``make black`` or ``hatch run lint:black`` to apply it.

.. _Black code style: https://github.com/ambv/black/#the-black-code-style

Imports within python modules must be sorted according to the isort_
configuration in ``setup.cfg``. The command ``make isort-check`` or ``tox -e
run-isortcheck`` checks whether all imports are sorted correctly, and ``make
isort`` or ``tox -e run-isort`` modifies all Python modules in-place with the
proper sorting.
configuration in ``pyproject.toml``. The command ``make isort-check`` or
``hatch run lint:isort-check`` checks whether all imports are sorted correctly,
and ``make isort`` or ``hatch run lint:isort`` modifies all Python modules
in-place with the proper sorting.

.. _isort: https://github.com/timothycrosley/isort#readme

Expand All @@ -317,8 +297,8 @@ requirements. These hooks are managed through the `pre-commit framework`_.

.. _pre-commit framework: https://pre-commit.com

You may use ``make flake8-check`` or ``tox -e run-flake8`` and ``make
pylint-check`` or ``tox -e run-pylint`` for additional checks on the code with
You may use ``make flake8-check`` or ``hatch run lint:flake8`` and ``make
pylint-check`` or ``hatch run lint:pylint`` for additional checks on the code with
flake8_ and pylint_, but there is no strict requirement for a perfect score
with either one of these linters. They only serve as a guideline for code that
might be improved.
Expand Down Expand Up @@ -380,7 +360,7 @@ or

.. code-block:: shell
tox -e docs
hatch run docs:build
to generate the documentation locally.

Expand Down
10 changes: 8 additions & 2 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ History
=======


(next version)
--------------
1.3.0-dev (unreleased)
----------------------

* Bugfix: `∫gₐdt` and total functional were reported incorrectly (`#96`_, thanks to `@daviehh`_)
* Bugfix: Restrict `qutip` to version 4. Support for `qutip 5.0` will be added in a later release
* Changed: Dropped support for Python 3.5 and Python 3.6
* Changed: The documentation will no longer be provided in PDF format
* Changed: Development is now organized around hatch_ instead of tox_


1.2.1 (2021-01-13)
Expand Down Expand Up @@ -135,6 +139,8 @@ Note: due to the changes in the time discretization of the controls and update s
.. _@loganbvh: https://github.com/loganbvh
.. _@daviehh: https://github.com/daviehh
.. _Alberto Castro: https://www.bifi.es/~acastro/
.. _hatch: https://hatch.pypa.io/latest/
.. _tox: https://tox.wiki/en/latest/
.. _#26: https://github.com/qucontrol/krotov/issues/26
.. _#29: https://github.com/qucontrol/krotov/issues/29
.. _#32: https://github.com/qucontrol/krotov/issues/32
Expand Down
Loading

0 comments on commit c143c7e

Please sign in to comment.