abczarr.api.entrypoint
Open Zarr arrays and groups through a selected backend driver.
open opens a location and returns the array or group there, wrapped in the uniform surface. When no driver is named, it reads the array's metadata and picks a driver that provides every codec the array needs, described in [select_driver][abczarr.drivers.base.select_driver], then opens through that driver. open_array and open_group additionally check what they opened.
Functions:
open
open(path: PathLike, mode: str = ..., *, asynchronous: Literal[False] = ..., driver: _DriverArg = ..., **fields: Any) -> ZarrNode
open(path: PathLike, mode: str = ..., *, asynchronous: Literal[True], driver: _DriverArg = ..., **fields: Any) -> Awaitable[AsyncZarrNode]
Open, or on a create mode create, the Zarr node at path.
The mode follows the h5py/zarr convention, so open both opens an
existing node and creates a new one:
| mode | if it exists | if it is missing |
|---|---|---|
"r" |
open read-only | error |
"r+" |
open read-write | error |
"a" |
open | create |
"w" |
overwrite | create |
"w-", "x" |
error | create |
On a create mode the keyword fields describe the new node.
These are the same fields create,
ArrayConfig and
GroupConfig accept. Array
parameters, such as a shape or a dtype, create an array. With
none, an empty group is created instead.
With asynchronous=True the return value is a coroutine that must
be awaited. It opens or creates path through the backend's own
async I/O and resolves to the coroutine twin of the node. Without
it, the node is opened synchronously and returned directly.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
PathLike
|
A local path or a URL, such as |
required |
mode
|
str
|
The access mode, in the h5py/zarr convention described in the table
above. |
'a'
|
asynchronous
|
bool
|
When true, return a coroutine that opens or creates |
False
|
driver
|
str or Driver
|
A driver, or its name, to open or create with. When omitted, a driver is chosen for what the node needs. |
None
|
**fields
|
Any
|
Creation parameters, consulted only on a create mode. These are the fields an ArrayConfig or GroupConfig accepts. |
{}
|
Returns:
| Type | Description |
|---|---|
ZarrNode or Awaitable[AsyncZarrNode]
|
The wrapped node directly, or, when |
open_array
open_array(path: PathLike, mode: str = ..., *, asynchronous: Literal[False] = ..., driver: _DriverArg = ..., **fields: Any) -> ZarrArray
open_array(path: PathLike, mode: str = ..., *, asynchronous: Literal[True], driver: _DriverArg = ..., **fields: Any) -> Awaitable[AsyncZarrArray]
Open path, requiring it to be an array.
This function behaves like open, but raises
if path is a group. On a create mode, fields must include
array parameters, at least a shape. Creating a group this way
is an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
PathLike
|
A local path or a URL, such as |
required |
mode
|
str
|
The access mode. See open for the modes and what each one does. |
'a'
|
asynchronous
|
bool
|
When true, return a coroutine that opens or creates |
False
|
driver
|
str or Driver
|
A driver, or its name, to open or create with. When omitted, a driver is chosen for what the array needs. |
None
|
**fields
|
Any
|
Creation parameters, consulted only on a create mode. These are the fields an ArrayConfig accepts. |
{}
|
Returns:
| Type | Description |
|---|---|
ZarrArray or Awaitable[AsyncZarrArray]
|
The wrapped array directly, or, when |
open_group
open_group(path: PathLike, mode: str = ..., *, asynchronous: Literal[False] = ..., driver: _DriverArg = ..., **fields: Any) -> ZarrGroup
open_group(path: PathLike, mode: str = ..., *, asynchronous: Literal[True], driver: _DriverArg = ..., **fields: Any) -> Awaitable[AsyncZarrGroup]
Open path, requiring it to be a group.
This function behaves like open, but raises
if path is an array. On a create mode, an empty group is
created. Array parameters are an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
PathLike
|
A local path or a URL, such as |
required |
mode
|
str
|
The access mode. See open for the modes and what each one does. |
'a'
|
asynchronous
|
bool
|
When true, return a coroutine that opens or creates |
False
|
driver
|
str or Driver
|
A driver, or its name, to open or create with. When omitted, a driver is chosen for what the group needs. |
None
|
**fields
|
Any
|
Creation parameters, consulted only on a create mode. These are the fields a GroupConfig accepts. |
{}
|
Returns:
| Type | Description |
|---|---|
ZarrGroup or Awaitable[AsyncZarrGroup]
|
The wrapped group directly, or, when |
create
create(location: PathLike, config: ArrayConfig | None = ..., *, data: Any, ome: Any = ..., asynchronous: Literal[False] = ..., **fields: Any) -> ZarrArray
create(location: PathLike, config: ArrayConfig | None = ..., *, data: Any, ome: Any = ..., asynchronous: Literal[True], **fields: Any) -> Awaitable[AsyncZarrArray]
create(location: PathLike, config: ArrayConfig, *, ome: Any = ..., asynchronous: Literal[False] = ..., **fields: Any) -> ZarrArray
create(location: PathLike, config: ArrayConfig, *, ome: Any = ..., asynchronous: Literal[True], **fields: Any) -> Awaitable[AsyncZarrArray]
create(location: PathLike, config: GroupConfig, *, ome: Any = ..., asynchronous: Literal[False] = ..., **fields: Any) -> ZarrGroup
create(location: PathLike, config: GroupConfig, *, ome: Any = ..., asynchronous: Literal[True], **fields: Any) -> Awaitable[AsyncZarrGroup]
create(location: PathLike, config: NodeMetadata, *, ome: Any = ..., asynchronous: Literal[False] = ..., **fields: Any) -> ZarrNode
create(location: PathLike, config: NodeMetadata, *, ome: Any = ..., asynchronous: Literal[True], **fields: Any) -> Awaitable[AsyncZarrNode]
Create the array or group config describes at location.
config is usually an ArrayConfig,
which creates an array, or a GroupConfig,
which creates a group. Keyword arguments override its fields, and the
backend creates the node natively. For full control beyond what the
config helpers express, config may instead be an exact metadata
document, an ArrayMetadata or
GroupMetadata, the lowered form a
config would produce. Such a document is created as it is, and there
driver and overwrite are the only accepted keywords. For a plain
dict, wrap it first with ArrayMetadata.from_json(...) or
ArrayConfig(**...).
An array is created from existing data when data is given. The array's
shape and dtype then default to the data's. A shape or dtype in
config or in the keyword arguments takes precedence over the data. The
data is written into the new array, and config, when given, must be an
ArrayConfig.
OME-Zarr metadata is written on the new node when ome is given. An
OME object or a plain mapping is written as it is.
An ImageConfig is lowered to base-level
metadata first.
With asynchronous=True the return value is a coroutine that must
be awaited. The backend creates through its own async I/O and
resolves to the coroutine twin of the node, mirroring async
open.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
PathLike
|
A local path or a URL, such as |
required |
config
|
(ArrayConfig, GroupConfig or NodeMetadata)
|
What to create. An |
None
|
data
|
array - like
|
Existing data to size the new array from and write into it. Requires
|
None
|
ome
|
(OME, ImageConfig or dict)
|
OME-Zarr metadata to write on the new node. |
None
|
asynchronous
|
bool
|
When true, return a coroutine that creates the node asynchronously and resolves to its coroutine twin. When false, the default, the node is created synchronously and returned directly. |
False
|
**fields
|
Any
|
Individual fields that override the same field on |
{}
|
Returns:
| Type | Description |
|---|---|
ZarrNode or Awaitable[AsyncZarrNode]
|
The newly created node directly, or, when |
create_group
create_group(location: PathLike, *, config: GroupConfig | None = ..., asynchronous: Literal[False] = ..., **fields: Any) -> ZarrGroup
create_group(location: PathLike, *, config: GroupConfig | None = ..., asynchronous: Literal[True], **fields: Any) -> Awaitable[AsyncZarrGroup]
Create a group at location, the metadata-free way.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
PathLike
|
A local path or a URL, such as |
required |
config
|
GroupConfig
|
A reusable GroupConfig. Individual
fields, such as |
None
|
asynchronous
|
bool
|
When true, return a coroutine that creates the group asynchronously and resolves to the async group twin, mirroring async create. When false, the default, the group is created synchronously and returned directly. |
False
|
**fields
|
Any
|
Individual GroupConfig fields
that override the same field on |
{}
|
Returns:
| Type | Description |
|---|---|
ZarrGroup or Awaitable[AsyncZarrGroup]
|
The newly created group directly, or, when |
create_array
create_array(location: PathLike, *, config: ArrayConfig | None = ..., asynchronous: Literal[False] = ..., **fields: Any) -> ZarrArray
create_array(location: PathLike, *, config: ArrayConfig | None = ..., asynchronous: Literal[True], **fields: Any) -> Awaitable[AsyncZarrArray]
Create an array at location, the metadata-free way.
At least a shape, and a dtype, is needed to describe the
array. A request with no array fields describes a group instead,
so create_group should be used for
that.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
PathLike
|
A local path or a URL, such as |
required |
config
|
ArrayConfig
|
A reusable ArrayConfig. Individual
fields, such as |
None
|
asynchronous
|
bool
|
When true, return a coroutine that creates the array asynchronously and resolves to the async array twin, mirroring async create. When false, the default, the array is created synchronously and returned directly. |
False
|
**fields
|
Any
|
Individual ArrayConfig fields
that override the same field on |
{}
|
Returns:
| Type | Description |
|---|---|
ZarrArray or Awaitable[AsyncZarrArray]
|
The newly created array directly, or, when |