Upgrading to the DataTree API#
Xpublish now treats xarray.DataTree as its core data primitive. A
bare xarray.Dataset is wrapped in a single-node tree internally,
so existing flat-dataset deployments and plugins keep working unchanged.
Nothing is deprecated. The notes below cover the new capabilities you can opt
into.
For server administrators#
This upgrade is transparent. Existing URLs, plugin loading, and configuration all behave the same. There are two new things you may want to surface:
Hierarchical datasets can now be published directly. Pass an
xarray.DataTree(or any mix of trees and Datasets) to the same APIs you already use:import xarray as xr import xpublish dt = xr.open_datatree("...") xpublish.Rest({"my-tree": dt}).serve(host="0.0.0.0", port=9000) # or, on a single tree: dt.rest.serve(host="0.0.0.0", port=9000)
New built-in endpoints on the
dataset_infoplugin (prefix/datasets/<dataset_id>):URL
Returns
/treeHTML repr of the full DataTree
/groupsJSON list of every group path
/groups/<path>HTML repr of the node at
<path>/groups/<path>/keysVariable keys at
<path>/groups/<path>/dictSchema dict at
<path>(no data)/groups/<path>/infoDetailed schema info at
<path>For flat datasets,
/groupsreturns["/"]and/groups/<path>/...returns 404.
For application embedders#
If your code instantiates xpublish.Rest or
xpublish.SingleDatasetRest directly, the type signatures have
widened — Datasets, DataTrees, or any mix are accepted. Internal storage is
now uniformly xarray.DataTree, so self._datasets[id] returns a
tree; access the root via tree.dataset.