Skip to content

Commit

Permalink
Release v0.7.0
Browse files Browse the repository at this point in the history
- New sampler implementation
- Serialization to the abstract representation
- Flexible sequence drawing
- Simulation with modulated output
  • Loading branch information
CdeTerra authored Aug 10, 2022
2 parents 9d978ab + 965ce51 commit c334524
Show file tree
Hide file tree
Showing 85 changed files with 5,670 additions and 2,501 deletions.
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ extend-ignore =
E203,
per-file-ignores =
# D100 Missing docstring in public module
# D101 Missing docstring in public class
# D102 Missing docstring in public method
# D103 Missing docstring in public function
# F401 Module imported but unused
tests/*: D100, D103
tests/*: D100, D101, D102, D103
__init__.py: F401
setup.py: D100
27 changes: 27 additions & 0 deletions .github/scripts/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

# Exit if something fails
set -e

# Find and change to the repository directory
repo_dir=$(git rev-parse --show-toplevel)
cd "${repo_dir}"

# Removing existing files in /dist
rm -rf dist

packages=$(cat packages.txt)
# Build the pulser packages
for pkg in $packages
do
echo "Packaging $pkg"
python $pkg/setup.py -q bdist_wheel -d "../dist"
rm -r $pkg/build
done

# Build the pulser metapackage
python setup.py -q bdist_wheel -d "dist"
rm -r build

echo "Built wheels:"
ls dist
73 changes: 23 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: build

on:
pull_request:
branches:
- master
- develop
push:
branches:
- master
Expand All @@ -15,83 +12,59 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out Pulser
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/checkout@v3
- name: Pulser + flake8 install
uses: ./.github/workflows/pulser-setup
with:
python-version: 3.8
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e ./pulser-core -e ./pulser-simulation
pip install -r requirements.txt
extra-packages: flake8
- name: Lint with flake8
run: flake8
black:
runs-on: ubuntu-latest
steps:
- name: Check out Pulser
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/checkout@v3
- name: Pulser + black install
uses: ./.github/workflows/pulser-setup
with:
python-version: 3.8
- name: Install black
run: |
python -m pip install --upgrade pip
pip install black
pip install 'black[jupyter]'
extra-packages: black
- name: Check formatting with black
run: black --check --diff .
isort:
runs-on: ubuntu-latest
steps:
- name: Check out Pulser
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/checkout@v3
- name: Pulser + isort install
uses: ./.github/workflows/pulser-setup
with:
python-version: 3.8
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e ./pulser-core -e ./pulser-simulation
pip install -r requirements.txt
extra-packages: isort
- name: Check import sorting with isort
run: isort --check-only --diff .
typing:
runs-on: ubuntu-latest
steps:
- name: Check out Pulser
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/checkout@v3
- name: Pulser + mypy install
uses: ./.github/workflows/pulser-setup
with:
python-version: 3.8
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e ./pulser-core -e ./pulser-simulation
pip install -r requirements.txt
extra-packages: '''mypy\|pytest'''
- name: Type check with mypy
run: mypy
test:
runs-on: ${{ matrix.os }}
if: github.event_name != 'push'
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.7, 3.8, 3.9, "3.10"]
python-version: ['3.7', '3.9']
steps:
- name: Check out Pulser
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/checkout@v3
- name: Pulser + pytest install
uses: ./.github/workflows/pulser-setup
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e ./pulser-core -e ./pulser-simulation
pip install -r requirements.txt
extra-packages: pytest
- name: Run the unit tests & generate coverage report
run: pytest --cov --cov-fail-under=100
79 changes: 79 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Upload Release Package to PyPI

on:
release:
types: [released]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Check out Pulser
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build packages
shell: bash
run: ./.github/scripts/package.sh
- name: Publish to TestPyPI
env:
TWINE_USERNAME: ${{ secrets.TESTPYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TESTPYPI_PASSWORD }}
run: twine upload --repository testpypi dist/*
- name: Install from TestPyPI
timeout-minutes: 5
shell: bash
run: |
version="$(head -1 VERSION.txt)"
until pip install -i https://test.pypi.org/simple/ pulser==$version --extra-index-url https://pypi.org/simple
do
echo "Failed to install from TestPyPI, will wait for upload and retry."
sleep 30
done
- name: Test the installation
# Installs pytest from dev_requirements.txt (in case it has a version specifier)
run: |
grep -e pytest dev_requirements.txt | sed 's/ //g' | xargs pip install
pytest
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*

check-release:
needs: deploy
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10']
steps:
- name: Check out Pulser
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Pulser from PyPI
shell: bash
run: |
python -m pip install --upgrade pip
pip install pulser
- name: Test the installation
shell: bash
run: |
version="$(head -1 VERSION.txt)"
python -c "import pulser; assert pulser.__version__ == '$version'"
grep -e pytest dev_requirements.txt | sed 's/ //g' | xargs pip install
pytest
31 changes: 31 additions & 0 deletions .github/workflows/pulser-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Pulser setup
description: "Sets up Python and installs Pulser."
inputs:
python-version:
description: Python version
required: false
default: '3.9'
extra-packages:
description: Extra packages to install (give to grep)
required: false
default: ''
runs:
using: 'composite'
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
cache: 'pip'
- name: Install Pulser
shell: bash
run: |
python -m pip install --upgrade pip
pip install -e ./pulser-core -e ./pulser-simulation
- name: Install extra packages from the dev requirements
if: "${{ inputs.extra-packages != '' }}"
shell: bash
run: |
grep -e ${{ inputs.extra-packages }} dev_requirements.txt \
| sed 's/ //g' \
| xargs pip install
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: test

on:
push:
branches:
- master
- develop

jobs:
full-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10']
steps:
- name: Check out Pulser
uses: actions/checkout@v3
- name: Pulser + pytest setup
uses: ./.github/workflows/pulser-setup
with:
python-version: ${{ matrix.python-version }}
extra-packages: pytest
- name: Run the unit tests & generate coverage report
run: pytest --cov --cov-fail-under=100
48 changes: 48 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: version

on:
pull_request:
paths:
- 'VERSION.txt'

jobs:
validate-version:
runs-on: ubuntu-latest
steps:
- name: Check out base branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Get old version
run: |
old_version="$(head -1 VERSION.txt)"
echo "Old version: $old_version"
echo "old_version=$old_version" >> $GITHUB_ENV
- name: Check out head branch
uses: actions/checkout@v3
- name: Get new version
run: |
new_version="$(head -1 VERSION.txt)"
echo "New version: $new_version"
echo "new_version=$new_version" >> $GITHUB_ENV
- name: Compare versions
run: dpkg --compare-versions "${{ env.old_version }}" lt "${{ env.new_version }}"
- name: Check stable version validity
if: github.event.pull_request.base.ref == 'master'
run: |
pattern=^\(0\|[1-9]\d*\)\.\(0\|[1-9]\d*\)\.\(0\|[1-9]\d*\)$
if [[ ${{ env.new_version }} =~ $pattern ]]; then
echo "New version is valid."; exit 0
else
echo "New version is invalid."; exit 1
fi
- name: Check development version validity
if: github.event.pull_request.base.ref != 'master'
run: |
pattern=^\(0\|[1-9]\d*\)\.\(0\|[1-9]\d*\)dev\(0\|[1-9]\d*\)$
if [[ ${{ env.new_version }} =~ $pattern ]]; then
echo "New version is valid."; exit 0
else
echo "New version is invalid."; exit 1
fi
2 changes: 1 addition & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ warn_unused_ignores = True
disallow_untyped_defs = True

# 3rd-party libs without type hints nor stubs
[mypy-matplotlib.*,scipy.*,qutip.*]
[mypy-matplotlib.*,scipy.*,qutip.*,jsonschema.*]
follow_imports = silent
ignore_missing_imports = true

Expand Down
10 changes: 7 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
# Required
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.9"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Optionally set the version of Python and requirements required to build your docs
# Optionally declare the Python requirements required to build your docs
python:
version: 3.8
install:
- requirements: docs/requirements.txt
- requirements: requirements.txt
- requirements: dev_requirements.txt
- requirements: pulser-core/rtd_requirements.txt
- requirements: pulser-simulation/rtd_requirements.txt
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Here are the steps you should follow to make your contribution:
We enforce some continuous integration standards in order to maintain the quality of Pulser's code. Make sure you follow them, otherwise your pull requests will be blocked until you fix them. To check if your changes pass all CI tests before you make the PR, you'll need additional packages, which you can install by running
```shell
pip install -r requirements.txt
pip install -r dev_requirements.txt
```
- **Tests**: We use [`pytest`](https://docs.pytest.org/en/latest/) to run unit tests on our code. If your changes break existing tests, you'll have to update these tests accordingly. Additionally, we aim for 100% coverage over our code. Try to cover all the new lines of code with simple tests, which should be placed in the `Pulser/pulser/tests` folder. To run all tests and check coverage, run:
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
include README.md
include requirements.txt
include LICENSE
include VERSION.txt
Loading

0 comments on commit c334524

Please sign in to comment.