feat(array): pa.from_xarray walks readers registered by each carrier's package, and a refusal lists every reason
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start with pipekit_array/bridges/xarray.py and the referenced q2_xarray_readers.py prototype; review #406 for the NoMatch contract. Implement the registry and from_xarray discovery behavior, including the named DimArray reader. Done means refusals report every reader and reason in order, imports stay lazy, and lint, type checks, and tests pass.
Written by the indexing model from the issue text.
Description
Problem / Request
Add a reader registry to pipekit_array.bridges.xarray and make pa.from_xarray(da) try each registered reader in priority order, returning the first carrier or raising one ValueError that lists each reader's name and reason. DimArray's reader is last and never declines.
Motivation
There are three entry points today, and each assumes the DataArray is its own. The prototype gave each carrier's DataArray to each reader:
| Reader | GeoArray's DataArray |
CField's DataArray |
DimArray's DataArray |
|---|---|---|---|
GeoArray.from_xarray |
GeoArray |
AttributeError |
ValueError: no grid |
CField.from_xarray |
CField at T, georeference dropped |
CField at U |
CField at T |
pipekit's from_xarray |
DimArray, georeference dropped |
DimArray on (y_c, x_g) |
DimArray |
A chain of the three, each returning a carrier or NoMatch(reason), picked the right carrier in all three cases. coordax does the same with NoCoordinateMatch (CP-D3).
Proposed API
# proposed (CP-D3)
# a reader returns a carrier or NoMatch(reason); one that raises is recorded as declining
def register_reader(name: str, reader: Callable[[xr.DataArray], Any], *, priority: int) -> None: ...
# DataArray → the first carrier a reader claims
def from_xarray(da: xr.DataArray, *, readers: tuple[str, ...] | None = None) -> Any: ...
# ValueError: no carrier reads this DataArray:
# geoarray: no spatial_ref coordinate
# gridax: no dim coordinate with an xgcm axis attribute
pa.from_xarray(da, readers=("geoarray", "gridax"))
Reuse
pipekit_array/bridges/xarray.py:from_xarraybecomes theDimArrayreader, unchanged.pipekit_ops.carriers.NoMatchfrom #406.
References & Existing Code
- Design:
docs/design/coordax_carriers.mdin jejjohnson/geostack (merged in jejjohnson/geostack#368), pattern 2 and question CP-O1. - Prototype:
q2_xarray_readers.py.
Implementation Steps
- The registry and
from_xarrayinpipekit_array/bridges/xarray.py, with the discovery CP-O1 decides (entry pointspipekit.readersrecommended). - Keep today's
DimArrayreader reachable by name (readers=("pipekit",)).
Definition of Done
- A DataArray no reader claims except
DimArray's reads as today. - A refusal lists every reader tried, in order, with its reason.
- A reader that raises is reported with the exception's type and first line.
-
import pipekit_arrayimports no reader package. - Lint, type check and tests green.
Relationships
- Parent: jejjohnson/geostack#369
- Blocked by: #406
- Blocks: jejjohnson/geotoolz#850, jejjohnson/gridax#628, #409
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 3h 50m
- Merged PRs (30d)
- 143
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jejjohnson/pipekit
-
area:code layer:0-primitives priority:p2 type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jejjohnson/pipekit#296 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 3/5 1-2 days Newbie friendliness 57/100
jejjohnson/pipekit#411 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 4/5 3-5 days Newbie friendliness 48/100
jejjohnson/pipekit#410 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 5/5 Over a week Newbie friendliness 38/100
jejjohnson/pipekit#409 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 3/5 1-2 days Newbie friendliness 75/100
jejjohnson/pipekit#408 ·
Maintainers usually reply within 1 day
All issues in jejjohnson/pipekit
Similar issues
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorPossibly taken @jejjohnson claimed this today. Opentype:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jejjohnson/integrix#144 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
finos/ai-governance-framework#459 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
freelawproject/litigant-portal#1307 ·
Maintainers usually reply within 2 days
-
type/bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
h2oai/h2o-llmstudio#1163 ·
Maintainers usually reply within 1 day