report_file = str(filename).replace('.nc', '_dask_report.html').replace('.h5', '_dask_report.html')
with LocalCluster(n_workers=1, threads_per_worker=threads, memory_limit=max_mem) as cluster:
with Client(cluster):
with performance_report(filename=report_file):
ds.to_netcdf(filename, compute=True, mode="w", engine="netcdf4", encoding=encoding)
2026-03-17 10:40:40,417 - distributed.protocol.pickle - ERROR - Failed to serialize <function performance_report.__aenter__.<locals>.<lambda> at 0x7f952868d430>.
Traceback (most recent call last):
File "/home/AD278604/bugmesh-GyselaX/venv/lib/python3.14/site-packages/distributed/protocol/pickle.py", line 63, in dumps
result = pickle.dumps(x, **dump_kwargs)
_pickle.PicklingError: Can't pickle local object <function performance_report.__aenter__.<locals>.<lambda> at 0x7f952868d430>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/AD278604/bugmesh-GyselaX/venv/lib/python3.14/site-packages/distributed/protocol/pickle.py", line 68, in dumps
pickler.dump(x)
~~~~~~~~~~~~^^^
_pickle.PicklingError: Can't pickle local object <function performance_report.__aenter__.<locals>.<lambda> at 0x7f952868d430>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/AD278604/bugmesh-GyselaX/venv/lib/python3.14/site-packages/distributed/protocol/pickle.py", line 80, in dumps
result = cloudpickle.dumps(x, **dump_kwargs)
File "/data/gyselarunner/gyselalibxx-env-shared/.spack-env/view/lib/python3.14/site-packages/cloudpickle/cloudpickle.py", line 1479, in dumps
cp.dump(obj)
~~~~~~~^^^^^
File "/data/gyselarunner/gyselalibxx-env-shared/.spack-env/view/lib/python3.14/site-packages/cloudpickle/cloudpickle.py", line 1245, in dump
return super().dump(obj)
~~~~~~~~~~~~^^^^^
File "/data/gyselarunner/gyselalibxx-env-shared/.spack-env/view/lib/python3.14/site-packages/cloudpickle/cloudpickle.py", line 1330, in reducer_override
return self._function_reduce(obj)
~~~~~~~~~~~~~~~~~~~~~^^^^^
File "/data/gyselarunner/gyselalibxx-env-shared/.spack-env/view/lib/python3.14/site-packages/cloudpickle/cloudpickle.py", line 1208, in _function_reduce
return self._dynamic_function_reduce(obj)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "/data/gyselarunner/gyselalibxx-env-shared/.spack-env/view/lib/python3.14/site-packages/cloudpickle/cloudpickle.py", line 1193, in _dynamic_function_reduce
state = _function_getstate(func)
File "/data/gyselarunner/gyselalibxx-env-shared/.spack-env/view/lib/python3.14/site-packages/cloudpickle/cloudpickle.py", line 707, in _function_getstate
f_globals_ref = _extract_code_globals(func.__code__)
File "/data/gyselarunner/gyselalibxx-env-shared/.spack-env/view/lib/python3.14/site-packages/cloudpickle/cloudpickle.py", line 306, in _extract_code_globals
out_names = _extract_code_globals_cache.get(co)
File "/data/gyselarunner/spack-1.1.1/opt/spack/gcc-13.2.0/python-3.14.0-4kfz7z3gxo3d6sqri2vut6rmjutx7w7k/lib/python3.14/weakref.py", line 357, in get
return self.data.get(ref(key),default)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
RecursionError: Stack overflow (used 8160 kB) in comparison
when serializing function reconstructor
Describe the issue:
Minimal Complete Verifiable Example:
The error encountered:
Environment: