Skip to content

abczarr.api.registry

The registry of backend drivers, and driver selection for an array.

abczarr opens Zarr through a Driver. This module holds the list of drivers it knows about. Given an array's metadata, it picks the driver that can read the array. This selection is the machinery behind open.

Functions:

register_driver

register_driver(module: str, cls: str, name: str = '') -> None

Register a driver by the module and class that provide it.

The driver is imported and instantiated only when available_drivers is called. Registering a driver never imports its backend.

Parameters:

Name Type Description Default
module str

The dotted path of the module that defines the driver class.

required
cls str

The name of the driver class within module.

required
name str

The name the driver is selected by, for example through open(..., driver=name).

''

available_drivers

available_drivers() -> list[Driver]

The installed, usable drivers, in preference order.

Each known driver is imported and instantiated. A driver whose backend is not installed, so that its available property is False, is left out. A driver that cannot be imported at all is also left out.

select_driver

select_driver(metadata: ArrayMetadata, drivers: Iterable[Driver]) -> Driver

Return the first driver in drivers that can open metadata.

Parameters:

Name Type Description Default
metadata ArrayMetadata

The array's metadata, describing the features a driver must support to open it.

required
drivers iterable of Driver

The candidate drivers, considered in order.

required

Returns:

Type Description
Driver

The first driver among drivers that can open metadata.

Raises:

Type Description
[UnsupportedZarrOperation][UnsupportedZarrOperation]

If none of drivers can open metadata. The message names each candidate driver and the feature it is missing, so the failure points at the exact gap rather than at a backend's opaque error.