API reference
Top-level Rest class
The Rest
class can be used for publishing a
a collection of xarray.Dataset
objects.
The main interfaces to Xpublish that many users may use.
|
Used to publish multiple Xarray Datasets via a REST API (FastAPI application). |
Returns the |
|
Returns the |
|
Returns the loaded plugins |
|
|
Serve this FastAPI application via |
|
Register a plugin with the xpublish system |
FastAPI dependencies to pass to plugin router methods |
There are also a handful of methods that are more likely to be used when subclassing xpublish.Rest to modify functionality, or are used by plugin dependencies.
|
Initialize datasets and dataset accessor function |
Return dataset ids from directly loaded datasets and plugins |
|
|
Attempt to load dataset from plugins, otherwise return dataset from passed in dictionary of datasets |
|
Initialize and load plugins from entry_points unless explicitly provided |
|
Set up cache kwargs |
|
Set up FastAPI application kwargs |
Load the app and dataset routers for plugins |
There is also a specialized version of xpublish.Rest
for use
when only a single dataset is being served, instead of a collection
of datasets.
|
Used to publish a single Xarray dataset via a REST API (FastAPI application). |
|
Modifies the dataset loading to instead connect to the single dataset |
For serving a single dataset the SingleDatasetRest
is used instead.
|
Used to publish a single Xarray dataset via a REST API (FastAPI application). |
Dataset.rest (xarray accessor)
This accessor extends xarray.Dataset
with the same interface than
SingleDatasetRest
. It is a convenient method for publishing one single
dataset. Proper use of this accessor should be like:
>>> import xarray as xr # first import xarray
>>> import xpublish # import xpublish (the dataset 'rest' accessor is registered)
>>> ds = xr.Dataset() # create or load an xarray Dataset
>>> ds.rest(...) # call the 'rest' accessor on the dataset
>>> ds.rest.<meth_or_prop> # access to the methods and properties listed below
Calling the accessor
|
Initialize this accessor by setting optional configuration values. |
Properties
Returns the |
|
Returns the |
Methods
|
Serve this FastAPI application via |
FastAPI dependencies
The functions below are defined in module xpublish.dependencies
and can
be used as FastAPI dependencies
when creating custom API endpoints directly.
When creating routers with plugins, instead use xpublish.Dependency
that will be
passed in to the Plugin.app_router
or Plugin.dataset_router
method.
FastAPI dependency for getting the list of ids (string keys) of the collection of datasets being served. |
|
|
FastAPI dependency for accessing the published xarray dataset object. |
FastAPI dependency for accessing the application's cache. |
|
|
FastAPI dependency that returns a dictionary of zarr encoded variables. |
|
FastAPI dependency that returns a consolidated zmetadata dictionary. |
FastAPI dependency that returns the a dictionary of loaded plugins |
|
Return the active plugin manager |
Plugins
Plugins are inherit from the Plugin
class, and implement various hooks.
Xpublish plugins provide ways to extend the core of xpublish with new routers and other functionality. |
|
Decorator helper class for marking functions as hook implementations. |
|
Decorator helper class for marking functions as hook specifications. |
|
A set of dependencies that are passed into plugin routers. |
|
Plugin extension points |
|
Find Xpublish plugins from entry point group xpublish.plugin |
|
Find and initialize plugins from entry point group xpublish.plugin |
|
|
Initialize and configure plugins with given dictionary of configurations |