Skip to content

fix: make opened arrays picklable for dask.distributed - #92

Open
earlybard wants to merge 1 commit into
developmentseed:mainfrom
earlybard:fix/pickle-for-distributed
Open

earlybard wants to merge 1 commit into
developmentseed:mainfrom
earlybard:fix/pickle-for-distributed

Conversation

@earlybard

Copy link
Copy Markdown
Contributor

Computing a chunked array on a dask.distributed cluster fails:

with dask.distributed.Client(processes=True):
    lazycogs.open("items.parquet", ..., chunks={"time": 1}).compute()
# TypeError: Could not serialize object of type _HLGExprSequence
# ...caused by TypeError: cannot pickle 'builtins.DuckdbClient' object

The backend array holds rustac's DuckdbClient, which can't be pickled. When open() makes the client, the array now drops it when pickled and makes a fresh DuckdbClient() when unpickled.

A client passed as duckdb_client= is pickled as it is. It may carry settings a default client wouldn't have, such as hive partitioning or credentials set with execute(), so it has to be picklable itself. The docstring and the chunking guide say so, and that href must be readable from every worker.

Tests round-trip an opened array through pickle and compare its values, and check that a caller's client isn't swapped out. I also ran it by hand on a LocalCluster(processes=True).

This will conflict with #88 in _backend.py (the docstring, and _dst_to_4326). Happy to rebase whichever lands second.

🤖 Generated with Claude Code

@earlybard

Copy link
Copy Markdown
Contributor Author

The Lint failure here is from ruff 0.17's new rules hitting main, not this change. #95 fixes it, and this passes lint with the repo's locked ruff (0.15.20).

The backend array held rustac's DuckdbClient, which can't be pickled, so
computing a chunked array on a dask.distributed cluster failed with
"Could not serialize object of type _HLGExprSequence". When open() makes
the client, the array now drops it when pickled and makes a fresh one when
unpickled. A client the caller passes is pickled as is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hrodmn
hrodmn force-pushed the fix/pickle-for-distributed branch from d4cf3e4 to 366ea00 Compare November 18, 2026 02:43

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant