Skip to content

Commit 428fba7

Browse files
authored
Update CI Python version to 3.12. (#3429)
* Update CI Python version to 3.12. * Try Python 3.11 as there is some problem with ruff. * Go back to Python version 3.12 after fixing formatting to comply with latest versions of black and ruff. * Try going back to Python 3.11. * Fix to comply with PEP 612 (see microsoft/pyright#5844 (comment)). * Fix typo * Go back to previous runtime.py and ignore mypy PEP 612 check. * Back to Python 3.12, * Back to Python 3.11. * Update Sphinx version to 0.5.0. * Update Sphinx version to 8.2.3. * Try removing Sphnix version in order solve dependency conflict. * List all Python modules for CI debug. * Try with Python 3.12 due to jaraco/path#231. * Unpin setuptools version. * Updated Sphinx version to 7.3.7. * Fix Sphinx issue (works on local machine). * Remove unused import. * Try different Sphinx versions. * Use Sphnix upgrade path. * Convert random seed to int data type. * Update levy-stable kstest. * Mark easyguide/test_easyguide.py::test_serialize as an expected failure according to the bug mentioned at #3430.
1 parent bfe88ed commit 428fba7

File tree

15 files changed

+56
-59
lines changed

15 files changed

+56
-59
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
strategy:
2222
matrix:
23-
python-version: [3.8]
23+
python-version: [3.12]
2424
steps:
2525
- uses: actions/checkout@v2
2626
- name: Set up Python ${{ matrix.python-version }}
@@ -29,7 +29,7 @@ jobs:
2929
python-version: ${{ matrix.python-version }}
3030
- name: Install dependencies
3131
run: |
32-
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
32+
python -m pip install --upgrade pip wheel setuptools
3333
pip install ruff black mypy nbstripout nbformat
3434
- name: Lint
3535
run: |
@@ -39,7 +39,7 @@ jobs:
3939
needs: lint
4040
strategy:
4141
matrix:
42-
python-version: [3.8]
42+
python-version: [3.12]
4343
steps:
4444
- uses: actions/checkout@v2
4545
- name: Set up Python ${{ matrix.python-version }}
@@ -51,12 +51,13 @@ jobs:
5151
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
5252
sudo apt-get update
5353
sudo apt-get install gcc-9 g++-9 ninja-build graphviz
54-
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
54+
python -m pip install --upgrade pip wheel setuptools
5555
# Keep track of pyro-api master branch
5656
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
5757
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
5858
pip install .[test]
5959
pip install -r docs/requirements.txt
60+
pip install --upgrade sphinx docutils sphinx-rtd-theme
6061
pip freeze
6162
- name: Build docs and run doctest
6263
run: |
@@ -67,7 +68,7 @@ jobs:
6768
needs: lint
6869
strategy:
6970
matrix:
70-
python-version: [3.8]
71+
python-version: [3.12]
7172
steps:
7273
- uses: actions/checkout@v2
7374
- name: Set up Python ${{ matrix.python-version }}
@@ -79,7 +80,7 @@ jobs:
7980
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
8081
sudo apt-get update
8182
sudo apt-get install gcc-9 g++-9 ninja-build graphviz pandoc
82-
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
83+
python -m pip install --upgrade pip wheel setuptools
8384
# Keep track of pyro-api master branch
8485
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
8586
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
@@ -101,7 +102,7 @@ jobs:
101102
needs: docs
102103
strategy:
103104
matrix:
104-
python-version: [3.8]
105+
python-version: [3.12]
105106
steps:
106107
- uses: actions/checkout@v2
107108
- name: Set up Python ${{ matrix.python-version }}
@@ -113,7 +114,7 @@ jobs:
113114
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
114115
sudo apt-get update
115116
sudo apt-get install gcc-9 g++-9 ninja-build
116-
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
117+
python -m pip install --upgrade pip wheel setuptools
117118
# Keep track of pyro-api master branch
118119
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
119120
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
@@ -133,7 +134,7 @@ jobs:
133134
needs: [docs, tutorials-html]
134135
strategy:
135136
matrix:
136-
python-version: [3.8]
137+
python-version: [3.12]
137138
steps:
138139
- uses: actions/checkout@v2
139140
- name: Set up Python ${{ matrix.python-version }}
@@ -147,7 +148,7 @@ jobs:
147148
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
148149
sudo apt-get update
149150
sudo apt-get install gcc-9 g++-9 ninja-build
150-
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
151+
python -m pip install --upgrade pip wheel setuptools
151152
# Keep track of pyro-api master branch
152153
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
153154
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
@@ -169,7 +170,7 @@ jobs:
169170
needs: docs
170171
strategy:
171172
matrix:
172-
python-version: [3.8]
173+
python-version: [3.12]
173174
steps:
174175
- uses: actions/checkout@v2
175176
- name: Set up Python ${{ matrix.python-version }}
@@ -181,7 +182,7 @@ jobs:
181182
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
182183
sudo apt-get update
183184
sudo apt-get install gcc-9 g++-9 ninja-build
184-
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
185+
python -m pip install --upgrade pip wheel setuptools
185186
# Keep track of pyro-api master branch
186187
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
187188
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
@@ -201,7 +202,7 @@ jobs:
201202
needs: docs
202203
strategy:
203204
matrix:
204-
python-version: [3.8]
205+
python-version: [3.12]
205206
steps:
206207
- uses: actions/checkout@v2
207208
- name: Set up Python ${{ matrix.python-version }}
@@ -213,7 +214,7 @@ jobs:
213214
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
214215
sudo apt-get update
215216
sudo apt-get install gcc-9 g++-9 ninja-build
216-
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
217+
python -m pip install --upgrade pip wheel setuptools
217218
# Keep track of pyro-api master branch
218219
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
219220
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
@@ -233,7 +234,7 @@ jobs:
233234
needs: docs
234235
strategy:
235236
matrix:
236-
python-version: [3.8]
237+
python-version: [3.12]
237238
steps:
238239
- uses: actions/checkout@v2
239240
- name: Set up Python ${{ matrix.python-version }}
@@ -245,7 +246,7 @@ jobs:
245246
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
246247
sudo apt-get update
247248
sudo apt-get install gcc-9 g++-9 ninja-build
248-
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
249+
python -m pip install --upgrade pip wheel setuptools
249250
# Keep track of pyro-api master branch
250251
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
251252
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
@@ -267,7 +268,7 @@ jobs:
267268
runs-on: ubuntu-latest
268269
strategy:
269270
matrix:
270-
python-version: [3.8]
271+
python-version: [3.12]
271272
steps:
272273
- uses: actions/checkout@v2
273274
- name: Set up Python ${{ matrix.python-version }}

docs/source/conf.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import os
55
import sys
66

7-
import sphinx_rtd_theme
8-
97
# import pkg_resources
108

119
# -*- coding: utf-8 -*-
@@ -82,7 +80,7 @@
8280

8381
if "READTHEDOCS" not in os.environ:
8482
# if developing locally, use pyro.__version__ as version
85-
from pyro import __version__ # noqaE402
83+
from pyro import __version__ # noqa: E402
8684

8785
version = __version__
8886

@@ -122,7 +120,6 @@
122120
# a list of builtin themes.
123121
#
124122
html_theme = "sphinx_rtd_theme"
125-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
126123

127124
# Theme options are theme-specific and customize the look and feel of a theme
128125
# further. For a list of options available for each theme, see the

examples/contrib/epidemiology/sir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def evaluate(args, model, samples):
177177
mean = samples[key].mean().item()
178178
std = samples[key].std().item()
179179
logging.info(
180-
"{}: truth = {:0.3g}, estimate = {:0.3g} \u00B1 {:0.3g}".format(
180+
"{}: truth = {:0.3g}, estimate = {:0.3g} \u00b1 {:0.3g}".format(
181181
key, getattr(args, name), mean, std
182182
)
183183
)

examples/sir_hmc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def evaluate(args, samples):
486486
mean = samples[key].mean().item()
487487
std = samples[key].std().item()
488488
logging.info(
489-
"{}: truth = {:0.3g}, estimate = {:0.3g} \u00B1 {:0.3g}".format(
489+
"{}: truth = {:0.3g}, estimate = {:0.3g} \u00b1 {:0.3g}".format(
490490
key, getattr(args, name), mean, std
491491
)
492492
)

examples/sparse_regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def main(args):
295295
with torch.no_grad():
296296
init_losses.append(loss_fn(model, guide, X, Y, hypers).item())
297297

298-
pyro.set_rng_seed(np.argmin(init_losses))
298+
pyro.set_rng_seed(int(np.argmin(init_losses)))
299299
pyro.clear_param_store()
300300
guide = AutoDelta(model, init_loc_fn=init_loc_fn)
301301

examples/toy_mixture_model_discrete_enumeration.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
"""
5-
A toy mixture model to provide a simple example for implementing discrete enumeration.
6-
7-
(A) -> [B] -> (C)
8-
9-
A is an observed Bernoulli variable with Beta prior.
10-
B is a hidden variable which is a mixture of two Bernoulli distributions (with Beta priors),
11-
chosen by A being true or false.
12-
C is observed, and like B, is a mixture of two Bernoulli distributions (with Beta priors),
13-
chosen by B being true or false.
14-
There is a plate over the three variables for n independent observations of data.
15-
16-
Because B is hidden and discrete we wish to marginalize it out of the model.
17-
This is done by:
18-
1) marking the model method with `@pyro.infer.config_enumerate`
19-
2) marking the B sample site in the model with `infer={"enumerate": "parallel"}`
20-
3) passing `pyro.infer.SVI` the `pyro.infer.TraceEnum_ELBO` loss function
5+
A toy mixture model to provide a simple example for implementing discrete enumeration.
6+
7+
(A) -> [B] -> (C)
8+
9+
A is an observed Bernoulli variable with Beta prior.
10+
B is a hidden variable which is a mixture of two Bernoulli distributions (with Beta priors),
11+
chosen by A being true or false.
12+
C is observed, and like B, is a mixture of two Bernoulli distributions (with Beta priors),
13+
chosen by B being true or false.
14+
There is a plate over the three variables for n independent observations of data.
15+
16+
Because B is hidden and discrete we wish to marginalize it out of the model.
17+
This is done by:
18+
1) marking the model method with `@pyro.infer.config_enumerate`
19+
2) marking the B sample site in the model with `infer={"enumerate": "parallel"}`
20+
3) passing `pyro.infer.SVI` the `pyro.infer.TraceEnum_ELBO` loss function
2121
"""
2222

2323
import argparse

pyro/contrib/epidemiology/compartmental.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def transition(self, params, state, t): ...
100100
model = MyModel(...)
101101
model.fit_svi(num_samples=100) # or .fit_mcmc(...)
102102
R0 = model.samples["R0"] # An example parameter.
103-
print("R0 = {:0.3g} \u00B1 {:0.3g}".format(R0.mean(), R0.std()))
103+
print("R0 = {:0.3g} \u00b1 {:0.3g}".format(R0.mean(), R0.std()))
104104
105105
# Predict latent variables.
106106
samples = model.predict()

pyro/contrib/gp/models/sgpr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class SparseGPRegression(GPModel):
1919
the covariance matrix :math:`k(X, X)` will require a lot of computational steps to
2020
compute its inverse (for log likelihood and for prediction). By introducing an
2121
additional inducing-input parameter :math:`X_u`, we can reduce computational cost
22-
by approximate :math:`k(X, X)` by a low-rank Nystr\u00F6m approximation :math:`Q`
22+
by approximate :math:`k(X, X)` by a low-rank Nystr\u00f6m approximation :math:`Q`
2323
(see reference [1]), where
2424
2525
.. math:: Q = k(X, X_u) k(X_u,X_u)^{-1} k(X_u, X).
@@ -72,7 +72,7 @@ class SparseGPRegression(GPModel):
7272
References:
7373
7474
[1] `A Unifying View of Sparse Approximate Gaussian Process Regression`,
75-
Joaquin Qui\u00F1onero-Candela, Carl E. Rasmussen
75+
Joaquin Qui\u00f1onero-Candela, Carl E. Rasmussen
7676
7777
[2] `Variational learning of inducing variables in sparse Gaussian processes`,
7878
Michalis Titsias

pyro/nn/module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ def __getstate__(self) -> Dict[str, Any]:
824824

825825

826826
def pyro_method(
827-
fn: Callable[Concatenate[_PyroModule, _P], _T]
827+
fn: Callable[Concatenate[_PyroModule, _P], _T],
828828
) -> Callable[Concatenate[_PyroModule, _P], _T]:
829829
"""
830830
Decorator for top-level methods of a :class:`PyroModule` to enable pyro

pyro/poutine/block_messenger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _make_default_hide_fn(
8484

8585

8686
def _negate_fn(
87-
fn: Callable[["Message"], Optional[bool]]
87+
fn: Callable[["Message"], Optional[bool]],
8888
) -> Callable[["Message"], bool]:
8989
# typed version of lambda msg: not fn(msg)
9090
def negated_fn(msg: "Message") -> bool:

0 commit comments

Comments
 (0)