Skip to content

Commit f6ec474

Browse files
committed
Mechanism to inform users to update nutpie
1 parent 3bc1bb2 commit f6ec474

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

pymc/sampling/mcmc.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import contextlib
16+
import importlib.metadata
1617
import importlib.util
1718
import inspect
1819
import logging
@@ -87,6 +88,16 @@
8788

8889
NUTPIE_INSTALLED = importlib.util.find_spec("nutpie") is not None
8990

91+
# Bump when PyMC starts using a feature that requires a newer nutpie release.
92+
# Installed versions below this still work via fallback paths but get a FutureWarning
93+
# the first time they are used in a `pm.sample` call.
94+
_NUTPIE_MIN_SUPPORTED = (0, 16, 8)
95+
_NUTPIE_VERSION: tuple[int, ...] | None = (
96+
tuple(int(p) for p in importlib.metadata.version("nutpie").split(".")[:3])
97+
if NUTPIE_INSTALLED
98+
else None
99+
)
100+
90101

91102
sys.setrecursionlimit(10000)
92103

@@ -365,6 +376,14 @@ def _sample_external_nuts(
365376
raise ImportError(
366377
"nutpie not found. Install it with conda install -c conda-forge nutpie"
367378
)
379+
if _NUTPIE_VERSION is not None and _NUTPIE_VERSION < _NUTPIE_MIN_SUPPORTED:
380+
warnings.warn(
381+
f"nutpie {'.'.join(map(str, _NUTPIE_VERSION))} is installed; "
382+
f"support for nutpie < {'.'.join(map(str, _NUTPIE_MIN_SUPPORTED))} "
383+
"is deprecated and will be removed in a future PyMC release.",
384+
FutureWarning,
385+
stacklevel=3,
386+
)
368387
import nutpie
369388

370389
if initvals is not None:

0 commit comments

Comments
 (0)