Skip to content

Commit

Permalink
Merge branch 'main' into vi_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
junpenglao authored Dec 30, 2022
2 parents 40d8cfb + 17199c6 commit 7000b2f
Show file tree
Hide file tree
Showing 38 changed files with 223 additions and 3,099 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Benchmarks

on:
push:
branches:
- main

jobs:
benchmark:
name: Run benchmarks
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.10' ]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Set up benchmark environment
run: |
python -m pip install -U pip
pip install .
less requirements.txt | grep 'pytest\|chex' | xargs -i -t pip install {}
- name: Run benchmarks
run: |
pytest -vv -m benchmark
62 changes: 41 additions & 21 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,48 @@
name: Nightly

on:
schedule:
- cron: "0 0 * * *"
push:
branches: [main]

jobs:
build_and_publish:
name: Build source distribution
name: Build and publish on PyPi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: "3.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build
- name: Build the sdist
run: python -m build
env:
BUILD_BLACKJAX_NIGHTLY: true
- uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_NIGHTLY_TOKEN }}
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Update pyproject.toml
# Taken from https://github.com/aesara-devs/aesara/pull/1375
run: |
curl -sSLf https://github.com/TomWright/dasel/releases/download/v2.0.2/dasel_linux_amd64 \
-L -o /tmp/dasel && chmod +x /tmp/dasel
/tmp/dasel put -f pyproject.toml project.name -v blackjax-nightly
/tmp/dasel put -f pyproject.toml tool.setuptools_scm.version_scheme -v post-release
/tmp/dasel put -f pyproject.toml tool.setuptools_scm.local_scheme -v no-local-version
- name: Build the sdist and wheel
run: |
python -m pip install -U pip
python -m pip install build
python -m build
- name: Check sdist install and imports
run: |
mkdir -p test-sdist
cd test-sdist
python -m venv venv-sdist
venv-sdist/bin/python -m pip install ../dist/blackjax-nightly-*.tar.gz
venv-sdist/bin/python -c "import blackjax"
- name: Check wheel install and imports
run: |
mkdir -p test-wheel
cd test-wheel
python -m venv venv-wheel
venv-wheel/bin/python -m pip install ../dist/blackjax_nightly-*.whl
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_NIGHTLY_TOKEN }}
44 changes: 27 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,42 @@ on:

jobs:
release-job:
name: Release on PyPi
name: Build and publish on PyPi
runs-on: ubuntu-latest
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install release tooling
python-version: 3.9
- name: Build sdist and wheel
run: |
pip install twine wheel
- name: Build package
python -m pip install -U pip
python -m pip install build
python -m build
- name: Check that the package version matches the Release name
run: |
python setup.py sdist bdist_wheel
- name: Check that `blackjax.__version__` matches the Release name
run: |
echo "GITHUB_REF: ${GITHUB_REF}"
# The GITHUB_REF should be something like "refs/tags/v3.x.x"
# Make sure the package version is the same as the tag
grep -Rq "^Version: ${GITHUB_REF:10}$" blackjax.egg-info/PKG-INFO
- name: Publish to PyPi
- name: Check sdist install and imports
run: |
twine check dist/*
twine upload --repository pypi --username __token__ --password ${PYPI_TOKEN} dist/*
mkdir -p test-sdist
cd test-sdist
python -m venv venv-sdist
venv-sdist/bin/python -m pip install ../dist/blackjax-*.tar.gz
venv-sdist/bin/python -c "import blackjax"
- name: Check wheel install and imports
run: |
mkdir -p test-wheel
cd test-wheel
python -m venv venv-wheel
venv-wheel/bin/python -m pip install ../dist/blackjax-*.whl
venv-wheel/bin/python -c "import blackjax"
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

test-install-job:
name: Test install from PyPi
needs: release-job
Expand Down
62 changes: 21 additions & 41 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: pre-commit/action@v2.0.0

test:
Expand All @@ -24,44 +26,22 @@ jobs:
matrix:
python-version: [ '3.7', '3.10']
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dev environment & blackjax
run: |
python -m pip install --upgrade pip
pip install .
less requirements.txt | grep 'pytest\|chex' | xargs -i -t pip install {}
- name: Run the tests with pytest
run: |
pytest -n 4 -vv -m "not benchmark" --cov=blackjax --cov-report=xml --cov-report=term tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false

benchmark:
name: Run benchmarks
needs: [test]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.10' ]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dev environment & blackjax
run: |
python -m pip install --upgrade pip
pip install .
less requirements.txt | grep 'pytest\|chex' | xargs -i -t pip install {}
- name: Run the benchmarks with pytest-benchmark
run: |
pytest -n 4 -vv -m benchmark --cov=blackjax --cov-report=xml --cov-report=term tests
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Set up test environment
run: |
python -m pip install --upgrade pip
pip install .
less requirements.txt | grep 'pytest\|chex' | xargs -i -t pip install {}
- name: Run tests
run: |
pytest -n auto -vv -m "not benchmark" --cov=blackjax --cov-report=xml --cov-report=term tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
_version.py

# Installer logs
pip-log.txt
Expand Down
20 changes: 20 additions & 0 deletions .gitlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[title-max-length]
line-length=120

[title-min-length]
min-length=15

[title-match-regex]
# python-style regex that the commit-msg title must match
# Note that the regex can contradict with other rules if not used correctly
# (e.g. title-must-not-contain-word).
regex=^[A-Z].*$

[title-must-not-contain-word]
# Comma-separated list of words that should not occur in the title. Matching is case
# insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING"
# will not cause a violation, but "WIP: my title" will.
words=wip

[body-max-line-length]
line-length=72
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
exclude: |
(?x)^(
versioneer\.py|
blackjax/_version\.py|
)$
repos:
Expand Down Expand Up @@ -46,3 +45,8 @@ repos:
args: ['--profile=black']
- id: nbqa-flake8
args: ['--ignore=E501,E203,E302,E402,E731,W503']
- repo: https://github.com/jorisroovers/gitlint
rev: v0.18.0
hooks:
- id: gitlint
- id: gitlint-ci
7 changes: 3 additions & 4 deletions blackjax/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from blackjax._version import __version__

from .diagnostics import effective_sample_size as ess
from .diagnostics import potential_scale_reduction as rhat
from .kernels import (
Expand All @@ -22,6 +24,7 @@
from .optimizers import dual_averaging, lbfgs

__all__ = [
"__version__",
"dual_averaging", # optimizers
"lbfgs",
"hmc", # mcmc
Expand All @@ -44,7 +47,3 @@
"ess", # diagnostics
"rhat",
]

from . import _version

__version__ = _version.get_versions()["version"]
Loading

0 comments on commit 7000b2f

Please sign in to comment.