pydata / pydata/xarray

Add open_dataarray to BackendEntrypoint?

Open
#10,562 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Is your feature request related to a problem?

The BackendEntrypoint class at https://github.com/pydata/xarray/blob/1424972aec3d345a77daea182f6ca0239cb3497d/xarray/backends/common.py#L660-L738 currently has open_dataset and open_datatree methods, but not open_dataarray. Currently, someone implementing a BackendEntrypoint to do xarray.open_dataarray(..., engine="<something>") would have to implement open_dataset, and behind the scenes, this could result in a roundtrip xr.DataArray -> xr.Dataset -> xr.DataArray conversion, which can lead to some attributes/state getting lost along the way (xref https://github.com/pydata/xarray/issues/3268).

Describe the solution you'd like

Enable open_dataarray to be implemented directly, without a roundtrip conversion to/from xr.Dataset

Describe alternatives you've considered

No response

Additional context

https://github.com/GenericMappingTools/pygmt/pull/4008#discussion_r2224256129

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/common.py at the BackendEntrypoint class and read the existing open_dataset and open_datatree methods. Trace the xarray.open_dataarray engine path to understand where the backend entry point is selected. Done means a backend can provide open_dataarray directly without the DataArray-to-Dataset-to-DataArray roundtrip, with relevant behavior covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.