Skip to content

Commit 7000b2f

Browse files
authored
Merge branch 'main' into vi_dev
2 parents 40d8cfb + 17199c6 commit 7000b2f

38 files changed

+223
-3099
lines changed

.github/workflows/benchmark.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Benchmarks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
benchmark:
10+
name: Run benchmarks
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [ '3.10' ]
15+
steps:
16+
- uses: actions/checkout@v1
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Set up benchmark environment
22+
run: |
23+
python -m pip install -U pip
24+
pip install .
25+
less requirements.txt | grep 'pytest\|chex' | xargs -i -t pip install {}
26+
- name: Run benchmarks
27+
run: |
28+
pytest -vv -m benchmark

.github/workflows/nightly.yml

+41-21
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,48 @@
11
name: Nightly
2+
23
on:
3-
schedule:
4-
- cron: "0 0 * * *"
4+
push:
5+
branches: [main]
56

67
jobs:
78
build_and_publish:
8-
name: Build source distribution
9+
name: Build and publish on PyPi
910
runs-on: ubuntu-latest
1011
steps:
11-
- uses: actions/checkout@v2
12-
with:
13-
fetch-depth: 0
14-
- uses: actions/setup-python@v2
15-
with:
16-
python-version: "3.7"
17-
- name: Install dependencies
18-
run: |
19-
python -m pip install --upgrade pip
20-
python -m pip install --upgrade build
21-
- name: Build the sdist
22-
run: python -m build
23-
env:
24-
BUILD_BLACKJAX_NIGHTLY: true
25-
- uses: pypa/gh-action-pypi-publish@v1.4.2
26-
with:
27-
user: __token__
28-
password: ${{ secrets.PYPI_NIGHTLY_TOKEN }}
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.9
18+
- name: Update pyproject.toml
19+
# Taken from https://github.com/aesara-devs/aesara/pull/1375
20+
run: |
21+
curl -sSLf https://github.com/TomWright/dasel/releases/download/v2.0.2/dasel_linux_amd64 \
22+
-L -o /tmp/dasel && chmod +x /tmp/dasel
23+
/tmp/dasel put -f pyproject.toml project.name -v blackjax-nightly
24+
/tmp/dasel put -f pyproject.toml tool.setuptools_scm.version_scheme -v post-release
25+
/tmp/dasel put -f pyproject.toml tool.setuptools_scm.local_scheme -v no-local-version
26+
- name: Build the sdist and wheel
27+
run: |
28+
python -m pip install -U pip
29+
python -m pip install build
30+
python -m build
31+
- name: Check sdist install and imports
32+
run: |
33+
mkdir -p test-sdist
34+
cd test-sdist
35+
python -m venv venv-sdist
36+
venv-sdist/bin/python -m pip install ../dist/blackjax-nightly-*.tar.gz
37+
venv-sdist/bin/python -c "import blackjax"
38+
- name: Check wheel install and imports
39+
run: |
40+
mkdir -p test-wheel
41+
cd test-wheel
42+
python -m venv venv-wheel
43+
venv-wheel/bin/python -m pip install ../dist/blackjax_nightly-*.whl
44+
- name: Publish to PyPi
45+
uses: pypa/gh-action-pypi-publish@v1.4.2
46+
with:
47+
user: __token__
48+
password: ${{ secrets.PYPI_NIGHTLY_TOKEN }}

.github/workflows/release.yml

+27-17
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,42 @@ on:
77

88
jobs:
99
release-job:
10-
name: Release on PyPi
10+
name: Build and publish on PyPi
1111
runs-on: ubuntu-latest
12-
env:
13-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
1412
steps:
1513
- uses: actions/checkout@v2
1614
- name: Set up Python
17-
uses: actions/setup-python@v1
15+
uses: actions/setup-python@v2
1816
with:
19-
python-version: 3.7
20-
- name: Install release tooling
17+
python-version: 3.9
18+
- name: Build sdist and wheel
2119
run: |
22-
pip install twine wheel
23-
- name: Build package
20+
python -m pip install -U pip
21+
python -m pip install build
22+
python -m build
23+
- name: Check that the package version matches the Release name
2424
run: |
25-
python setup.py sdist bdist_wheel
26-
- name: Check that `blackjax.__version__` matches the Release name
27-
run: |
28-
echo "GITHUB_REF: ${GITHUB_REF}"
29-
# The GITHUB_REF should be something like "refs/tags/v3.x.x"
30-
# Make sure the package version is the same as the tag
3125
grep -Rq "^Version: ${GITHUB_REF:10}$" blackjax.egg-info/PKG-INFO
32-
- name: Publish to PyPi
26+
- name: Check sdist install and imports
3327
run: |
34-
twine check dist/*
35-
twine upload --repository pypi --username __token__ --password ${PYPI_TOKEN} dist/*
28+
mkdir -p test-sdist
29+
cd test-sdist
30+
python -m venv venv-sdist
31+
venv-sdist/bin/python -m pip install ../dist/blackjax-*.tar.gz
32+
venv-sdist/bin/python -c "import blackjax"
33+
- name: Check wheel install and imports
34+
run: |
35+
mkdir -p test-wheel
36+
cd test-wheel
37+
python -m venv venv-wheel
38+
venv-wheel/bin/python -m pip install ../dist/blackjax-*.whl
39+
venv-wheel/bin/python -c "import blackjax"
40+
- name: Publish to PyPi
41+
uses: pypa/gh-action-pypi-publish@v1.4.2
42+
with:
43+
user: __token__
44+
password: ${{ secrets.PYPI_TOKEN }}
45+
3646
test-install-job:
3747
name: Test install from PyPi
3848
needs: release-job

.github/workflows/test.yml

+21-41
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v2
1515
- uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.9
1618
- uses: pre-commit/action@v2.0.0
1719

1820
test:
@@ -24,44 +26,22 @@ jobs:
2426
matrix:
2527
python-version: [ '3.7', '3.10']
2628
steps:
27-
- uses: actions/checkout@v1
28-
- name: Set up Python ${{ matrix.python-version }}
29-
uses: actions/setup-python@v1
30-
with:
31-
python-version: ${{ matrix.python-version }}
32-
- name: Install dev environment & blackjax
33-
run: |
34-
python -m pip install --upgrade pip
35-
pip install .
36-
less requirements.txt | grep 'pytest\|chex' | xargs -i -t pip install {}
37-
- name: Run the tests with pytest
38-
run: |
39-
pytest -n 4 -vv -m "not benchmark" --cov=blackjax --cov-report=xml --cov-report=term tests
40-
- name: Upload coverage to Codecov
41-
uses: codecov/codecov-action@v1
42-
with:
43-
env_vars: OS,PYTHON
44-
name: codecov-umbrella
45-
fail_ci_if_error: false
46-
47-
benchmark:
48-
name: Run benchmarks
49-
needs: [test]
50-
runs-on: ubuntu-latest
51-
strategy:
52-
matrix:
53-
python-version: [ '3.10' ]
54-
steps:
55-
- uses: actions/checkout@v1
56-
- name: Set up Python ${{ matrix.python-version }}
57-
uses: actions/setup-python@v1
58-
with:
59-
python-version: ${{ matrix.python-version }}
60-
- name: Install dev environment & blackjax
61-
run: |
62-
python -m pip install --upgrade pip
63-
pip install .
64-
less requirements.txt | grep 'pytest\|chex' | xargs -i -t pip install {}
65-
- name: Run the benchmarks with pytest-benchmark
66-
run: |
67-
pytest -n 4 -vv -m benchmark --cov=blackjax --cov-report=xml --cov-report=term tests
29+
- uses: actions/checkout@v1
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v1
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
- name: Set up test environment
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install .
38+
less requirements.txt | grep 'pytest\|chex' | xargs -i -t pip install {}
39+
- name: Run tests
40+
run: |
41+
pytest -n auto -vv -m "not benchmark" --cov=blackjax --cov-report=xml --cov-report=term tests
42+
- name: Upload coverage to Codecov
43+
uses: codecov/codecov-action@v1
44+
with:
45+
env_vars: OS,PYTHON
46+
name: codecov-umbrella
47+
fail_ci_if_error: false

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ share/python-wheels/
3030
.installed.cfg
3131
*.egg
3232
MANIFEST
33+
_version.py
3334

3435
# Installer logs
3536
pip-log.txt

.gitlint

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[title-max-length]
2+
line-length=120
3+
4+
[title-min-length]
5+
min-length=15
6+
7+
[title-match-regex]
8+
# python-style regex that the commit-msg title must match
9+
# Note that the regex can contradict with other rules if not used correctly
10+
# (e.g. title-must-not-contain-word).
11+
regex=^[A-Z].*$
12+
13+
[title-must-not-contain-word]
14+
# Comma-separated list of words that should not occur in the title. Matching is case
15+
# insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING"
16+
# will not cause a violation, but "WIP: my title" will.
17+
words=wip
18+
19+
[body-max-line-length]
20+
line-length=72

.pre-commit-config.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
exclude: |
22
(?x)^(
3-
versioneer\.py|
43
blackjax/_version\.py|
54
)$
65
repos:
@@ -46,3 +45,8 @@ repos:
4645
args: ['--profile=black']
4746
- id: nbqa-flake8
4847
args: ['--ignore=E501,E203,E302,E402,E731,W503']
48+
- repo: https://github.com/jorisroovers/gitlint
49+
rev: v0.18.0
50+
hooks:
51+
- id: gitlint
52+
- id: gitlint-ci

blackjax/__init__.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from blackjax._version import __version__
2+
13
from .diagnostics import effective_sample_size as ess
24
from .diagnostics import potential_scale_reduction as rhat
35
from .kernels import (
@@ -22,6 +24,7 @@
2224
from .optimizers import dual_averaging, lbfgs
2325

2426
__all__ = [
27+
"__version__",
2528
"dual_averaging", # optimizers
2629
"lbfgs",
2730
"hmc", # mcmc
@@ -44,7 +47,3 @@
4447
"ess", # diagnostics
4548
"rhat",
4649
]
47-
48-
from . import _version
49-
50-
__version__ = _version.get_versions()["version"]

0 commit comments

Comments
 (0)