registry¶
Functions for registering and retrieving stat functions and data loaders. Third-party packages extend gridstats by declaring entry points in the gridstats.stats or gridstats.loaders groups — see Plugins.
gridstats.registry
¶
Registry for stat functions and data loaders.
Third-party packages can extend gridstats without modifying library code by declaring entry points in their package metadata:
[project.entry-points."gridstats.stats"]
my_stat = "my_package.module:my_stat_function"
[project.entry-points."gridstats.loaders"]
my_loader = "my_package.module:MyLoaderClass"
Built-in ops and loaders self-register via the @register_stat and @register_loader decorators when their modules are imported.
register_stat(name: str) -> Callable[[StatFn], StatFn]
¶
Decorator to register a stat function under a given name.
register_loader(name: str) -> Callable[[LoaderCls], LoaderCls]
¶
Decorator to register a data loader class under a given name.
get_stat(name: str) -> StatFn
¶
Return the registered stat function for the given name.
Raises:
| Type | Description |
|---|---|
KeyError
|
If no stat is registered under that name. |
get_loader(name: str) -> LoaderCls
¶
Return the registered loader class for the given name.
Raises:
| Type | Description |
|---|---|
KeyError
|
If no loader is registered under that name. |
list_stats() -> list[str]
¶
Return sorted names of all registered stat functions.
list_loaders() -> list[str]
¶
Return sorted names of all registered loaders.