Skip to content

Commit ec710c6

Browse files
lobisjpivarski
authored andcommitted
fix: dask distributed fsspec issue (#1065)
* add dask distributed to dev dependencies * work on test for issue 1063 * test multiple handlers * file handle pickling * clear file handle before pickling
1 parent e64da31 commit ec710c6

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ requires-python = ">=3.8"
5353
dev = [
5454
"boost_histogram>=0.13",
5555
"dask-awkward>=2023.12.1",
56-
"dask[array]",
56+
"dask[array,distributed]",
5757
"hist>=1.2",
5858
"pandas",
5959
"awkward-pandas"

src/uproot/source/fsspec.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def __repr__(self):
6161
return f"<{type(self).__name__} {path} at 0x{id(self):012x}>"
6262

6363
def __getstate__(self):
64+
self._fh = None
6465
state = dict(self.__dict__)
6566
state.pop("_executor")
6667
state.pop("_file")

tests/test_1063_dask_distributed.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pytest
2+
import skhep_testdata
3+
4+
import uproot
5+
import uproot.source.file
6+
import uproot.source.fsspec
7+
8+
dask = pytest.importorskip("dask")
9+
dask_awkward = pytest.importorskip("dask_awkward")
10+
dask_distributed = pytest.importorskip("dask.distributed")
11+
12+
13+
@pytest.mark.parametrize(
14+
"handler",
15+
[None, uproot.source.file.MemmapSource, uproot.source.fsspec.FSSpecSource],
16+
)
17+
def test_issue_1063(handler):
18+
file_path = skhep_testdata.data_path("uproot-issue121.root")
19+
20+
with dask_distributed.Client():
21+
events = uproot.dask({file_path: "Events"}, handler=handler)
22+
dask.compute(events.Muon_pt)

0 commit comments

Comments
 (0)