pydata / pydata/xarray

Enable object_codec in zarr backend

Open
#7,866 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

What is your issue?

The issue is that I am not able to define a custom object codec and use it for encoding particular variables in an xarray Dataset. I found a workaround that requires small changes to two files as follows.

Currently in the zarr backend of xarray, the allowed keys in the encoding dictionary are

{
        "chunks",
        "compressor",
        "filters",
        "cache_metadata",
        "write_empty_chunks",
}

Would it be possible to add object_codec to enable the use of custom codecs on object datatypes (change in xarray/backends/zarr.py)? Also would require ensure_dtype_not_object to be removed from conventions.py and placed in the backends as the TODO there suggests.

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 in xarray/backends/zarr.py by reviewing the allowed encoding keys, then follow the TODO concerning ensure_dtype_not_object in conventions.py. The work is complete when custom object codecs can be supplied for selected object-dtype variables and the related dtype handling is located in the backend as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 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.