pydata / pydata/xarray

Cannot pickle '_io.BufferedReader' object exception after DataArray transpose and copy operations when using fsspec filecache.

Open
#8,443 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic-backends
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

What is your issue?

We hit this issue while using rioxarray with a series of operations similar to those noted in this issue https://github.com/corteva/rioxarray/issues/711. After looking through the rioxarray codebase a bit I was able to reproduce the issue with pure xarray operations.

When opening a Dataset with fsspec local caching enabled, transposing a DataArray's coordinates and then copying the DataArray results in a cannot pickle '_io.BufferedReader' object exception.

The issue can be reproduced using this sample notebook.

Note that when using the filecache option with fsspec.filesystem the exception occurs immediately. When using the blockcache option the exception only occurs after a second copy call which is presumably using cached data.

This issue seems potentially related to the fsspec investigation in https://github.com/fsspec/filesystem_spec/issues/579#issuecomment-1140377495 but interestingly only seems reproducible with this incantation of transpose followed by copy.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked sample notebook and reproduce the transpose-then-copy sequence using fsspec filecache, then compare it with blockcache behavior. The issue names no repository files or tests; done means the reproduced DataArray operations no longer raise the BufferedReader pickle exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.