提交 e126020a authored 作者: Virgile Andreani's avatar Virgile Andreani 提交者: Ricardo Vieira

Fix pickling errors with python 3.14

上级 1a9fc1ed
...@@ -395,11 +395,8 @@ def test_linking_patch(listdir_mock, platform): ...@@ -395,11 +395,8 @@ def test_linking_patch(listdir_mock, platform):
] ]
def test_cache_race_condition(): @config.change_flags(on_opt_error="raise", on_shape_error="raise")
with tempfile.TemporaryDirectory() as dir_name: def _f_build_cache_race_condition(factor):
@config.change_flags(on_opt_error="raise", on_shape_error="raise")
def f_build(factor):
# Some of the caching issues arise during constant folding within the # Some of the caching issues arise during constant folding within the
# optimization passes, so we need these config changes to prevent the # optimization passes, so we need these config changes to prevent the
# exceptions from being caught # exceptions from being caught
...@@ -407,6 +404,9 @@ def test_cache_race_condition(): ...@@ -407,6 +404,9 @@ def test_cache_race_condition():
f = pytensor.function([a], factor * a) f = pytensor.function([a], factor * a)
return f(np.array([1], dtype=config.floatX)) return f(np.array([1], dtype=config.floatX))
def test_cache_race_condition():
with tempfile.TemporaryDirectory() as dir_name:
ctx = multiprocessing.get_context() ctx = multiprocessing.get_context()
compiledir_prop = pytensor.config._config_var_dict["compiledir"] compiledir_prop = pytensor.config._config_var_dict["compiledir"]
...@@ -425,7 +425,7 @@ def test_cache_race_condition(): ...@@ -425,7 +425,7 @@ def test_cache_race_condition():
# A random, constant input to prevent caching between runs # A random, constant input to prevent caching between runs
factor = rng.random() factor = rng.random()
procs = [ procs = [
ctx.Process(target=f_build, args=(factor,)) ctx.Process(target=_f_build_cache_race_condition, args=(factor,))
for i in range(num_procs) for i in range(num_procs)
] ]
for proc in procs: for proc in procs:
......
...@@ -247,9 +247,12 @@ def test_config_pickling(): ...@@ -247,9 +247,12 @@ def test_config_pickling():
configparser.IntParam(5, lambda i: i > 0), configparser.IntParam(5, lambda i: i > 0),
in_c_key=False, in_c_key=False,
) )
# Python 3.14 emits a pickle.PicklingError
# previous versions used to emit an AttributeError
# the error string changed a little bit too
with pytest.raises( with pytest.raises(
AttributeError, (AttributeError, pickle.PicklingError),
match=r"Can't (pickle|get) local object 'test_config_pickling\.<locals>\.<lambda>'", match=r"Can't (pickle|get) local object .*test_config_pickling\.<locals>\.<lambda>",
): ):
pickle.dump(root, io.BytesIO()) pickle.dump(root, io.BytesIO())
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论