Item handler: fall back to Zarr asset or raise a clear error (#68) - #69
Open
ghostiee-11 wants to merge 1 commit into
Open
Item handler: fall back to Zarr asset or raise a clear error (#68)#69ghostiee-11 wants to merge 1 commit into
ghostiee-11 wants to merge 1 commit into
Conversation
When `xpystac.to_xarray(item)` is called on a `pystac.Item` that has no kerchunk reference, the existing handler runs off the end of the function and returns None. That None then propagates up to xarray's backend, which dereferences `dataset.variables` and raises an opaque `AttributeError: 'NoneType' object has no attribute 'variables'` from deep inside `_protect_dataset_variables_inplace`. Tested live against Earth Search NAIP (https://earth-search.aws.element84.com/v1) and reproduced in the lumen STACSource path (holoviz/lumen#1867): client = pystac_client.Client.open('https://earth-search.aws.element84.com/v1') item = next(client.search(collections=['naip'], max_items=1).items()) xr.open_dataset(item, engine='stac') # AttributeError: 'NoneType' object has no attribute 'variables' Add an explicit fallback in the Item handler: * If the Item has any Zarr / icechunk asset, dispatch to the registered Asset handler with that asset. This means an item that ships a dataset-level asset alongside other formats now opens cleanly. * Otherwise, raise a `ValueError` naming the observed media_types and, if the item has a COG asset (the common case), pointing the user at stackstac / odc-stac which are the right tools for COG-only items. Fixes stac-utils#68. Added two regression tests against the existing `simple_item` fixture (its only assets are COG + thumbnail, mirroring NAIP's shape).
Author
|
Hey @jsignell, please check into this!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When
xpystac.to_xarray(item)is called on apystac.Itemthat has no kerchunk reference, the existing handler runs off the end of the function and returnsNone. ThatNonethen propagates up to xarray's backend, which dereferencesdataset.variablesand raises an opaqueAttributeError: 'NoneType' object has no attribute 'variables'from deep inside_protect_dataset_variables_inplace.Reproduced on the live Earth Search NAIP catalog and in the Lumen STACSource path (holoviz/lumen#1867):
Fix
Add an explicit fallback in the Item handler:
ValueErrornaming the observedmedia_typesand, if the item has a COG asset (the common case), pointing the user atstackstac/odc-stac, which are the right tools for COG-only items.After the fix, the same snippet returns a clean error:
Tests
Added two regression tests against the existing
simple_itemfixture (its only assets are COG + thumbnail, mirroring NAIP's shape). All existing core tests stay green;test_to_xarray_reference_filewas already failing onmainin my env (unrecognized engine 'kerchunk') and is unrelated.Fixes #68.