Skip to content

Commit 68ebb5b

Browse files
github-actions[bot]AlexeyKozhevindependabot[bot]Copilot
authored
Release r0.10.1 (#824)
* Update version to 0.10.1 * Bump fonttools from 4.55.8 to 4.60.2 Bumps [fonttools](https://github.com/fonttools/fonttools) from 4.55.8 to 4.60.2. - [Release notes](https://github.com/fonttools/fonttools/releases) - [Changelog](https://github.com/fonttools/fonttools/blob/main/NEWS.rst) - [Commits](fonttools/fonttools@4.55.8...4.60.2) --- updated-dependencies: - dependency-name: fonttools dependency-version: 4.60.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Bump nbconvert from 7.16.6 to 7.17.0 Bumps [nbconvert](https://github.com/jupyter/nbconvert) from 7.16.6 to 7.17.0. - [Release notes](https://github.com/jupyter/nbconvert/releases) - [Changelog](https://github.com/jupyter/nbconvert/blob/main/CHANGELOG.md) - [Commits](jupyter/nbconvert@v7.16.6...v7.17.0) --- updated-dependencies: - dependency-name: nbconvert dependency-version: 7.17.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump protobuf from 6.32.0 to 6.33.5 Bumps [protobuf](https://github.com/protocolbuffers/protobuf) from 6.32.0 to 6.33.5. - [Release notes](https://github.com/protocolbuffers/protobuf/releases) - [Commits](https://github.com/protocolbuffers/protobuf/commits) --- updated-dependencies: - dependency-name: protobuf dependency-version: 6.33.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Bump urllib3 from 2.3.0 to 2.6.3 Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.3.0 to 2.6.3. - [Release notes](https://github.com/urllib3/urllib3/releases) - [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst) - [Commits](urllib3/urllib3@2.3.0...2.6.3) --- updated-dependencies: - dependency-name: urllib3 dependency-version: 2.6.3 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump filelock from 3.17.0 to 3.20.3 Bumps [filelock](https://github.com/tox-dev/py-filelock) from 3.17.0 to 3.20.3. - [Release notes](https://github.com/tox-dev/py-filelock/releases) - [Changelog](https://github.com/tox-dev/filelock/blob/main/docs/changelog.rst) - [Commits](tox-dev/filelock@3.17.0...3.20.3) --- updated-dependencies: - dependency-name: filelock dependency-version: 3.20.3 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Bump jupyterlab from 4.3.5 to 4.4.8 Bumps [jupyterlab](https://github.com/jupyterlab/jupyterlab) from 4.3.5 to 4.4.8. - [Release notes](https://github.com/jupyterlab/jupyterlab/releases) - [Changelog](https://github.com/jupyterlab/jupyterlab/blob/main/RELEASE.md) - [Commits](https://github.com/jupyterlab/jupyterlab/compare/@jupyterlab/lsp@4.3.5...@jupyterlab/lsp@4.4.8) --- updated-dependencies: - dependency-name: jupyterlab dependency-version: 4.4.8 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Bump tornado from 6.4.2 to 6.5.5 Bumps [tornado](https://github.com/tornadoweb/tornado) from 6.4.2 to 6.5.5. - [Changelog](https://github.com/tornadoweb/tornado/blob/master/docs/releases.rst) - [Commits](tornadoweb/tornado@v6.4.2...v6.5.5) --- updated-dependencies: - dependency-name: tornado dependency-version: 6.5.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Bump requests from 2.32.3 to 2.33.0 Bumps [requests](https://github.com/psf/requests) from 2.32.3 to 2.33.0. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md) - [Commits](psf/requests@v2.32.3...v2.33.0) --- updated-dependencies: - dependency-name: requests dependency-version: 2.33.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump pygments from 2.19.1 to 2.20.0 Bumps [pygments](https://github.com/pygments/pygments) from 2.19.1 to 2.20.0. - [Release notes](https://github.com/pygments/pygments/releases) - [Changelog](https://github.com/pygments/pygments/blob/master/CHANGES) - [Commits](pygments/pygments@2.19.1...2.20.0) --- updated-dependencies: - dependency-name: pygments dependency-version: 2.20.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Bump onnx from 1.18.0 to 1.21.0 Bumps [onnx](https://github.com/onnx/onnx) from 1.18.0 to 1.21.0. - [Release notes](https://github.com/onnx/onnx/releases) - [Changelog](https://github.com/onnx/onnx/blob/main/docs/Changelog-ml.md) - [Commits](onnx/onnx@v1.18.0...v1.21.0) --- updated-dependencies: - dependency-name: onnx dependency-version: 1.21.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump pillow from 10.4.0 to 12.2.0 Bumps [pillow](https://github.com/python-pillow/Pillow) from 10.4.0 to 12.2.0. - [Release notes](https://github.com/python-pillow/Pillow/releases) - [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst) - [Commits](python-pillow/Pillow@10.4.0...12.2.0) --- updated-dependencies: - dependency-name: pillow dependency-version: 12.2.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump pytest from 8.3.4 to 9.0.3 Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.3.4 to 9.0.3. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](pytest-dev/pytest@8.3.4...9.0.3) --- updated-dependencies: - dependency-name: pytest dependency-version: 9.0.3 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Change process to thread (#825) * Update batchflow/tests/detachable_test.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Apply changes * Minor changes --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: AlexeyKozhevin <19620584+AlexeyKozhevin@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Alexey Kozhevin <alexey.a.kozhevin@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 52d5c5b commit 68ebb5b

File tree

4 files changed

+363
-192
lines changed

4 files changed

+363
-192
lines changed

batchflow/plotter/plot.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from itertools import cycle
66
from numbers import Number
77
from warnings import warn
8-
from multiprocessing import Process
8+
from threading import Thread
99

1010
import numpy as np
1111

@@ -27,7 +27,7 @@
2727

2828
# Decorators
2929
def detachable(func):
30-
""" Run `func` in a daemon process without result return.
30+
""" Run `func` in a daemon thread without result return.
3131
3232
Note, the decorator intercept the `detach` argument from the `func`.
3333
"""
@@ -36,9 +36,9 @@ def _wrapper(*args, **kwargs):
3636
detach = kwargs.get('detach', False)
3737

3838
if detach is True:
39-
process = Process(target=func, args=args, kwargs=kwargs,
40-
daemon=True, name=f'daemon_for_{func.__qualname__}')
41-
process.start()
39+
thread = Thread(target=func, args=args, kwargs=kwargs,
40+
daemon=True, name=f'daemon_for_{func.__qualname__}')
41+
thread.start()
4242
return None
4343

4444
result = func(*args, **kwargs)
@@ -952,10 +952,10 @@ class Plot:
952952
If False, every time `plot` is called update config with provided keyword arguments, replacing older parameters.
953953
If True, fix plotter config as provided on initialization. Usefull, if one want to reuse this config on updates.
954954
detach : {True, False, 'save'}, default: False
955-
Whether to use run `plot` in a daemon process.
956-
If False, then don't use any daemon processes.
957-
If True, then run :meth:`~.plot` in a daemon process.
958-
If 'save', then run :meth:`~.save` (called from the :meth:`~.plot`) in a daemon process.
955+
Whether to use run `plot` in a daemon thread.
956+
If False, then don't use any daemon threads.
957+
If True, then run :meth:`~.plot` in a daemon thread.
958+
If 'save', then run :meth:`~.save` (called from the :meth:`~.plot`) in a daemon thread.
959959
kwargs :
960960
- For one of `image`, `histogram`, `curve`, `loss` methods of `Layer` (depending on chosen mode).
961961
Parameters and data nestedness levels must match if they are lists meant for differents subplots/layers.
@@ -1691,9 +1691,9 @@ def save(self, **kwargs):
16911691

16921692
if savepath:
16931693
if detach:
1694-
process = Process(target=self.figure.savefig, kwargs={'fname': savepath, **save_config},
1695-
daemon=True, name=f'daemon_for_{self.save.__qualname__}')
1696-
process.start()
1694+
thread = Thread(target=self.figure.savefig, kwargs={'fname': savepath, **save_config},
1695+
daemon=True, name=f'daemon_for_{self.save.__qualname__}')
1696+
thread.start()
16971697
else:
16981698
self.figure.savefig(fname=savepath, **save_config)
16991699

batchflow/tests/detachable_test.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"""Test that the detachable decorator and Plot.save work with detach=True.
2+
3+
The original implementation used multiprocessing.Process which fails on Python 3.14
4+
due to a pickling error: `@wraps(func)` preserves `__qualname__`, so pickle resolves
5+
`Plot.plot` by name and finds the wrapper instead of the original function.
6+
7+
Replacing Process with Thread avoids pickling entirely — figure saving doesn't need
8+
process isolation.
9+
"""
10+
11+
import os
12+
import tempfile
13+
import time
14+
15+
import numpy as np
16+
17+
18+
def _wait_for_file(path, timeout=5):
19+
"""Poll until `path` exists or `timeout` seconds elapse."""
20+
deadline = time.monotonic() + timeout
21+
while not os.path.exists(path) and time.monotonic() < deadline:
22+
time.sleep(0.05)
23+
24+
25+
def test_detachable_plot_with_detach():
26+
"""Plot.plot with detach='save' should complete without PicklingError."""
27+
from batchflow.plotter.plot import Plot
28+
29+
data = np.random.rand(10, 10)
30+
with tempfile.TemporaryDirectory() as tmpdir:
31+
savepath = os.path.join(tmpdir, "test_detach.png")
32+
p = Plot(data=data, mode="image", show=False, detach='save', savepath=savepath)
33+
_wait_for_file(savepath)
34+
assert p is not None
35+
assert os.path.exists(savepath)
36+
37+
38+
def test_plot_save_with_detach():
39+
"""Plot.save with detach=True should complete without PicklingError."""
40+
from batchflow.plotter.plot import Plot
41+
42+
data = np.random.rand(10, 10)
43+
with tempfile.TemporaryDirectory() as tmpdir:
44+
savepath = os.path.join(tmpdir, "test_save_detach.png")
45+
p = Plot(data=data, mode="image", show=False, savepath=savepath)
46+
assert os.path.exists(savepath)
47+
48+
savepath2 = os.path.join(tmpdir, "test_save_detach2.png")
49+
p.save(savepath=savepath2, detach=True)
50+
_wait_for_file(savepath2)
51+
assert os.path.exists(savepath2)
52+
53+
54+
def test_detachable_plot_without_detach():
55+
"""Plot.plot with detach=False (default) should work as before."""
56+
from batchflow.plotter.plot import Plot
57+
58+
data = np.random.rand(10, 10)
59+
with tempfile.TemporaryDirectory() as tmpdir:
60+
savepath = os.path.join(tmpdir, "test_no_detach.png")
61+
Plot(data=data, mode="image", show=False, savepath=savepath)
62+
assert os.path.exists(savepath)

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "batchflow"
3-
version = "0.10.0"
3+
version = "0.10.1"
44
description = "ML pipelines, model configuration and batch management"
55
authors = [{ name = "Roman Kh", email = "rhudor@gmail.com" }]
66
license = {text = "Apache License 2.0"}
@@ -31,7 +31,7 @@ dependencies = [
3131
[project.optional-dependencies]
3232

3333
image = [
34-
"pillow>=9.4,<11.0",
34+
"pillow>=9.4,<13.0",
3535
"matplotlib>=3.7"
3636
]
3737

@@ -71,7 +71,7 @@ jupyter = [
7171
]
7272

7373
telegram = [
74-
"pillow>=9.4,<11.0",
74+
"pillow>=9.4,<13.0",
7575
]
7676

7777
safetensors = [

0 commit comments

Comments
 (0)