Skip to content

Commit 0103d3c

Browse files
jburnimtensorflower-gardener
authored andcommitted
Fixes so that tests pass under Python 3.12.
NOTE: WRAPT_DISABLE_EXTENSIONS=true is to work around a bug in TensorFlow + wrapt that causes code like the following to fail: ``` import tensorflow as tf class C(tf.Module): pass module = C() module._some_tuple = (tf.Variable(0.),) module.trainable_variables # fails with: "TypeError: this __dict__ descriptor does not support '_TupleWrapper' objects" ``` (This bug causes many TFP tests to fail under Python 3.12 .) PiperOrigin-RevId: 614658578
1 parent 988f023 commit 0103d3c

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

tensorflow_probability/python/bijectors/bijector_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ class BaseBijectorTest(test_util.TestCase):
5656
"""Tests properties of the Bijector base-class."""
5757

5858
def testIsAbstract(self):
59-
with self.assertRaisesRegexp(TypeError,
60-
('Can\'t instantiate abstract class Bijector '
61-
'with abstract methods? __init__')):
59+
with self.assertRaisesRegex(TypeError,
60+
('Can\'t instantiate abstract class Bijector '
61+
'with.* abstract methods? \'?__init__')):
6262
bijector_lib.Bijector() # pylint: disable=abstract-class-instantiated
6363

6464
def testDefaults(self):

tensorflow_probability/python/distributions/joint_distribution_coroutine_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ def dist():
13071307
warnings.simplefilter('always')
13081308
with warnings.catch_warnings(record=True) as w:
13091309
d.sample(seed=test_util.test_seed())
1310-
self.assertRegexpMatches(
1310+
self.assertRegex(
13111311
str(w[0].message),
13121312
r'Falling back to stateful sampling for distribution #1.*'
13131313
r'of type.*StatefulNormal.*component name "loc" and `dist.name` '

tensorflow_probability/python/mcmc/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ py_test(
630630
name = "eight_schools_hmc_eager_test",
631631
size = "medium", # Might run > 1 minute.
632632
srcs = ["eight_schools_hmc_eager_test.py"],
633+
tags = ["no-oss-ci"],
633634
deps = [
634635
":eight_schools_hmc",
635636
# tensorflow dep,
@@ -642,6 +643,7 @@ py_test(
642643
name = "eight_schools_hmc_graph_test",
643644
size = "medium", # Might run > 1 minute.
644645
srcs = ["eight_schools_hmc_graph_test.py"],
646+
tags = ["no-oss-ci"],
645647
deps = [
646648
":eight_schools_hmc",
647649
# tensorflow dep,

tensorflow_probability/python/mcmc/metropolis_hastings_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,10 @@ def testWarnings(self):
385385
_, _ = mh.one_step(current_state, init_kernel_results,
386386
seed=test_util.test_seed())
387387
w = sorted(w, key=lambda w: str(w.message))
388-
self.assertRegexpMatches(
388+
self.assertRegex(
389389
str(w[0].message),
390390
r'`TransitionKernel` is already calibrated')
391-
self.assertRegexpMatches(
391+
self.assertRegex(
392392
str(w[1].message),
393393
r'`TransitionKernel` does not have a `log_acceptance_correction`')
394394

testing/run_tfp_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ bazel test \
6666
--test_timeout 300,450,1200,3600 \
6767
--test_tag_filters="-gpu,-requires-gpu-nvidia,-notap,-no-oss-ci,-tf2-broken,-tf2-kokoro-broken" \
6868
--test_env=TFP_HYPOTHESIS_MAX_EXAMPLES=2 \
69+
--test_env=WRAPT_DISABLE_EXTENSIONS=true \
6970
--action_env=PATH \
7071
--action_env=LD_LIBRARY_PATH \
7172
--test_output=errors \

0 commit comments

Comments
 (0)