Skip to content

[PoC] Add support for DataTrees#313

Open
alxthm wants to merge 1 commit into
xpublish-community:mainfrom
alxthm:alxthm/add-datatree-support
Open

[PoC] Add support for DataTrees#313
alxthm wants to merge 1 commit into
xpublish-community:mainfrom
alxthm:alxthm/add-datatree-support

Conversation

@alxthm
Copy link
Copy Markdown

@alxthm alxthm commented Dec 14, 2025

Add support for xr.DataTrees in addition to xr.Dataset, for the xpublish.Rest class.

This change is focused on unlocking support for multiscale overviews in plugins (see #92).

It is a proof of concept intended to support discussion.

Changes:

  • Extend xpublish Dependencies with DataTrees. New FastAPI dependencies get_datatree_ids and get_datatree are added and plugins can access them via the hooks (Dependencies.datatree_ids / Dependencies.datatree).
  • In the Rest class, add a '/datatrees/{datatree_id}' route prefix, for the above dependency.

This will allow plugins to define routes that serve DataTree data:

class TilesPlugin(Plugin):
    ...

    @hookimpl
    def datatree_router(self, deps: Dependencies):
        """Tiles endpoints for DataTree-based multiscale pyramids."""
        router = APIRouter(
            prefix=self.datatree_router_prefix, tags=self.datatree_router_tags
        )

        @router.get("/{tileMatrixSetId}/{tileMatrix}/{tileRow}/{tileCol}")
        async def get_datatree_tile(
            ...,
            datatree: DataTree = Depends(deps.datatree),
        ):
            ...

The xpublish.Rest class can now handle xr.DataTrees in addition
to xr.Dataset.
This will unlock support for multiscale overviews in plugins.

See xpublish-community#92
@mpiannucci
Copy link
Copy Markdown
Contributor

Thanks @alxthm ! Myself and @abkfenris will take a deep look at this soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants