Skip to content

Commit

Permalink
Merge branch 'beta' into master (will become v0.9.10 soon)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Nielsen committed Oct 4, 2021
2 parents 5ac4dbf + 75e8e50 commit 708bb00
Show file tree
Hide file tree
Showing 923 changed files with 173,674 additions and 98,516 deletions.
14 changes: 13 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,24 @@
# F401: module imported but unused
# F403: 'from module import *' used; unable to detect undefined names
# F405: name may be undefined, or defined from star imports: module
ignore=E265,E266,E402,E701,E702,E704,E722,E741,W503,W605,F401,F403,F405
# N806: variable in function should be lowercase
ignore=E265,E266,E402,E701,E702,E704,E722,E741,W503,W605,F401,F403,F405,N806

exclude=
# automatically generated
pygsti/io/parsetab_string.py
pygsti/modelpacks/smq*.py
pygsti/modelpacks/legacy/std*.py

#Allow legacyio to have names like 'GateString_setstate' and classes like 'dummy_GateString'
#Also allow report sections to have figure-factory methods whose first arg is 'workspace', not 'self'
# N801 : class name should not be mixed case
# N802 : function name should be lowercase
# N805 : first argument to method should be called 'self'
per-file-ignores =
pygsti/io/legacyio.py:N801,N802
pygsti/objects/replib/slowreplib.py:N802
pygsti/report/section/*.py:N805

# 120 characters is a more agreeable max line length for modern displays
max-line-length=120
16 changes: 15 additions & 1 deletion .flake8-critical
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,21 @@
[flake8]
# ONLY check for these linting errors:
# E9**: Runtime errors
# F63*: Invalid tests and comparisons
# F7**: Flake8 syntax errors
# F82*: Undefined names
# This list may be expanded in the future
select=E9,F7,F82
select=E9,F63,F7,F82

exclude=
# Known issues with rb tests. Currently skipped, but technically have F821 errors
test/unit/extras/rb/test_analysis.py
test/unit/extras/rb/test_group.py
test/unit/extras/rb/test_sample.py
test/unit/extras/rb/test_theory.py
test/unit/tools/test_internalgates.py
test/test_packages/extras/test_rb.py
# F821 error. Should nPossible be nLocal?
test/test_packages/drivers/nqubitconstruction.py
# F821 error. Likely results existed in a deleted cell
scripts/profiling/gaugeopt/3Q_example.py
8 changes: 8 additions & 0 deletions .github/ci-scripts/before_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

sudo apt-get update -qq -y && \
sudo apt-get install -qq -y \
gfortran libblas-dev liblapack-dev openmpi-bin openmpi-common openssh-client \
openssh-server libopenmpi2 libopenmpi-dev libsuitesparse-dev
cmake --version
gcc --version
63 changes: 63 additions & 0 deletions .github/ci-scripts/merge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#! /usr/bin/env bash
# This script is run by a GitHub Action
# This merges passing builds on the `deploy' branch to `beta'

GIT_USER="GitHub Action"
GIT_EMAIL="[email protected]"

# we should only be run during Action
if [ -z "$GITHUB_ACTIONS" ]; then
echo "This script is run automatically by GitHub Actions."
echo "Please don't run it manually!"
echo '... But if you really have to, set $GITHUB_ACTIONS to "true" to bypass this safety check.'
exit 1
fi

# trigger only on `develop' by default (configurable)
if [ -z "$TRIGGER_REF" ]; then
TRIGGER_REF="/refs/heads/develop"
fi

# push to `beta' by default (configurable)
if [ -z "$MERGE_BRANCH" ]; then
MERGE_BRANCH="beta"
fi

echo "GITHUB_REPOSITORY = $GITHUB_REPOSITORY"
echo "GITHUB_REF = $GITHUB_REF"
echo "TRIGGER_REF = $TRIGGER_REF"
echo "MERGE_BRANCH = $MERGE_BRANCH"

# Following should only be set for pull requests
PULL_REQUEST=false
if [ -z "$GITHUB_HEAD_REF" ] || [ -z "$GITHUB_BASE_REF" ]; then
PULL_REQUEST=true
fi
echo "PULL_REQUEST = $PULL_REQUEST"

if [ "$GITHUB_REF" = "$TRIGGER_REF" ] && [ "$PULL_REQUEST" = "false" ]; then
# setup git user
git config user.email "$GIT_EMAIL"
git config user.name "$GIT_USER"

# branch develop head to beta
git checkout -b "$MERGE_BRANCH"

# if branch exists upstream, apply it on top of this one
UPSTREAM_URI="[email protected]:$GITHUB_REPOSITORY.git"
UPSTREAM_BRANCH=$(git ls-remote --heads "$UPSTREAM_URI" "$MERGE_BRANCH")
if [ "$?" -eq 0 ] && [ -n "$UPSTREAM_BRANCH" ]; then
git pull --ff-only "$UPSTREAM_URI" "$MERGE_BRANCH"
if [ "$?" -eq 0 ]; then
echo "Fast-forwarded $MERGE_BRANCH to $TRIGGER_REF."
else
echo "ERROR: couldn't fast-forward $MERGE_BRANCH to $TRIGGER_REF!"
echo "These branches must be merged manually."
echo "hint: If you wish to merge these branches automatically in the future,"
echo "hint: add the conflicting refs from $PUSH BRANCH to $DEVELOP BRANCH."
exit 2
fi
fi
else
echo "Not triggering pull: GITHUB_REF != TRIGGER_REF or PULL_REQUEST != false"
fi
80 changes: 80 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Deploy new version on pypi.org

on:
push:
branches: [ "master" ]

# Allow running manually from Actions tab
workflow_dispatch:


jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # to fetch all branches and *tags* (needed to get version number correctly)

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: cp36-* cp37-* cp38-* cp39-*
CIBW_BUILD_VERBOSITY: 1
CIBW_BEFORE_ALL_LINUX: ./.github/ci-scripts/before_install.sh

- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # to fetch all branches and *tags* (needed to get version number correctly)

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'

- name: Build sdist
run: python setup.py sdist

- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist

- name: Publish package on PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
70 changes: 70 additions & 0 deletions .github/workflows/extras.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Build and run test extras

on:
push:
branches: [ "beta" ]
#pull_requests
# branches: [ "master", "develop", "beta" ]
# Allow running manually from Actions tab
workflow_dispatch:

env:
SKIP_DEAP: 1
NOSE_VERBOSE: 2
NOSE_WITH_TIMER: 1
NOSE_WITH_ID: 1
NOSE_REDNOSE: 1
NOSE_WITH_COVERAGE: 1
NOSE_COVER_PACKAGE: "pygsti"
NOSE_PROCESSES: -1
NOSE_NOPATH: ""
NOSE_PROCESS_TIMEOUT: 2400
NOSE_WHERE: "test/test_packages/"

jobs:
test_extras: # On stable branches, run extended tests

runs-on: ubuntu-18.04
strategy:
fail-fast: false # Finish all tests even if one fails
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
nose-tests:
- "algorithms algorithmsb"
- "report reportb"
- "drivers objects tools iotest optimize construction extras"
# - "mpi" # Fails in GitHub Actions, passes locally but doesn't terminate threads properly

steps:
- uses: actions/checkout@v2
- name: Set up installation environment
run: |
./.github/ci-scripts/before_install.sh
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}-${{ hashFiles('**/*requirements.txt') }}
- name: Install package
run: |
python -m pip install --upgrade pip
# Installing with -e to keep installation local (for NOSE_NOPATH)
# but still compile Cython extensions
python -m pip install -e .[testing]
- name: Run test_packages ${{ matrix.nose-tests }}
env:
NOSETESTS: ${{ matrix.nose-tests }}
run: |
python -Ic "import pygsti; print(pygsti.__version__); print(pygsti.__path__)"
echo "nosetests: $NOSETESTS"
nosetests $NOSETESTS
90 changes: 90 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Build and run tests

on:
push:
branches-ignore: [ "beta" ]
# Hacky way to only run pull requests from forked repositories (assumes : is not used in branch names unless forked)
# https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662/10
pull_request:
branches: [ "**:**" ]
# Allow running manually from Actions tab
workflow_dispatch:

env:
SKIP_DEAP: 1
NOSE_VERBOSE: 2
NOSE_WITH_TIMER: 1
NOSE_WITH_ID: 1
NOSE_REDNOSE: 1
NOSE_WITH_COVERAGE: 1
NOSE_COVER_PACKAGE: "pygsti"
NOSE_PROCESSES: -1
NOSE_NOPATH: 1 # use installed package, not source tree under CWD
NOSE_PROCESS_TIMEOUT: 2400
NOSE_WHERE: "test/unit/"

jobs:
build: # Main build + unit test check

runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up installation environment
run: |
./.github/ci-scripts/before_install.sh
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}-${{ hashFiles('**/*requirements.txt') }}
- name: Install package
run: |
python -m pip install --upgrade pip
python -m pip install flake8
python -m pip install .[testing]
# python -m pip freeze # this isn't relevant anymore since pip install builds a wheel separately
- name: Lint with flake8
run: |
# Critical errors, exit on failure
flake8 . --count --show-source --statistics --config=.flake8-critical
# Standard PEP8, allowed to fail since exit-zero treats all errors as warnings
flake8 . --exit-zero --statistics
- name: Run unit tests
run: |
python -Ic "import pygsti; print(pygsti.__version__); print(pygsti.__path__)"
echo "nosetests: $NOSETESTS"
nosetests $NOSETESTS
push: # Push to stable "beta" branch on successful build

runs-on: ubuntu-18.04

# Only run on "develop" branch if tests pass
needs: build
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.PYGSTI_TOKEN }}
- name: Merge changes to beta branch
run: |
git config --global user.name 'PyGSTi'
git config --global user.email '[email protected]'
git checkout beta
git merge --ff-only ${GITHUB_SHA} && git push origin beta
Loading

0 comments on commit 708bb00

Please sign in to comment.