xpublish.plugins.hooks.PluginSpec#

pydantic model xpublish.plugins.hooks.PluginSpec[source]#

Plugin extension points.

Plugins do not need to implement all of the methods defined here, instead they implement

Fields:

app_router(deps)[source]#

Create an app (top-level) router for the plugin.

Implementations should return an APIRouter, and define app_router_prefix, and app_router_tags on the class, and use those to initialize the router.

Return type:

APIRouter

dataset_router(deps)[source]#

Create a dataset router for the plugin.

Implementations should return an APIRouter, and define dataset_router_prefix, and dataset_router_tags on the class, and use those to initialize the router.

Return type:

APIRouter

get_dataset(dataset_id)[source]#

Return a xarray.Dataset for dataset_id.

Use this hook when your provider only serves flat datasets — Xpublish wraps the returned Dataset in a single-node xarray.DataTree internally. For hierarchical providers, implement get_datatree() instead, which also receives the requested group path.

Both hooks are first-class and may coexist; get_datatree() is consulted first.

If the plugin does not have the dataset, return None.

Return type:

Optional[Dataset]

get_datasets()[source]#

Return an iterable of dataset ids that the plugin can provide.

Return type:

Iterable[str]

get_datatree(dataset_id, group)[source]#

Return a xarray.DataTree for dataset_id rooted at group.

Implementations should declare group as a positional parameter (pluggy will not forward keyword-only parameters). An empty group string means “the root”.

Providers decide how to be smart about this. Providers that only ever serve flat datasets can return xr.DataTree(dataset=ds) (a single-node tree) and None for any non-empty group. Providers that have hierarchical data can return either the full tree (and index into it with group) or, for lazy backends, open only the requested group and wrap it in a single-node tree.

The returned tree’s root corresponds to the requested group.

If the plugin does not have the dataset, return None.

Return type:

Optional[DataTree]

register_hookspec()[source]#

Return additional hookspec class to register with the plugin manager.