提交 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):
]
def test_cache_race_condition():
with tempfile.TemporaryDirectory() as dir_name:
@config.change_flags(on_opt_error="raise", on_shape_error="raise")
def f_build(factor):
@config.change_flags(on_opt_error="raise", on_shape_error="raise")
def _f_build_cache_race_condition(factor):
# Some of the caching issues arise during constant folding within the
# optimization passes, so we need these config changes to prevent the
# exceptions from being caught
......@@ -407,6 +404,9 @@ def test_cache_race_condition():
f = pytensor.function([a], factor * a)
return f(np.array([1], dtype=config.floatX))
def test_cache_race_condition():
with tempfile.TemporaryDirectory() as dir_name:
ctx = multiprocessing.get_context()
compiledir_prop = pytensor.config._config_var_dict["compiledir"]
......@@ -425,7 +425,7 @@ def test_cache_race_condition():
# A random, constant input to prevent caching between runs
factor = rng.random()
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 proc in procs:
......
......@@ -247,9 +247,12 @@ def test_config_pickling():
configparser.IntParam(5, lambda i: i > 0),
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(
AttributeError,
match=r"Can't (pickle|get) local object 'test_config_pickling\.<locals>\.<lambda>'",
(AttributeError, pickle.PicklingError),
match=r"Can't (pickle|get) local object .*test_config_pickling\.<locals>\.<lambda>",
):
pickle.dump(root, io.BytesIO())
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论