cellmap_flow.io.paths

Dataset paths: where a container ends, how to join onto a path, what is there.

A dataset path is a local directory or an http(s), s3 or gs URL, and may run on past its container into the group or array inside it (/data/x.zarr/recon-1/em/s0). A precomputed:// path, and a gs:// path with no .zarr/.n5 in it, is a neuroglancer precomputed volume: precomputed:// is followed by a local directory or, as neuroglancer writes it, a URL (precomputed://gs://bucket/volume).

What is at a path is probed through io.store (for .zgroup, .zarray, zarr.json) only where a path has no .zarr/.n5 suffix to split it at; the local v3 checks look at the filesystem.

Attributes

ZARR_JSON

Functions

is_remote(→ bool)

An http(s), s3 or gs URL.

is_precomputed(→ bool)

A precomputed:// path, or a gs:// one that names no zarr or

normalize_path(→ str)

Remove shell-escape backslashes from a filesystem path.

join(→ str)

Join path components; a URL is joined with "/" whatever the OS.

parent(→ str)

The directory above path, a URL's as a local path's; a URL's root

is_v3_container(→ bool)

True if path is a directory with a zarr.json at its root.

find_v3_container(→ Optional[str])

The nearest directory at or above path holding a zarr.json.

is_zarr_container(→ bool)

A local zarr (v2 or v3) group or array, with or without a .zarr suffix.

suffix_format(→ Optional[str])

"zarr" or "n5": the suffix of the last component of path that ends

split_container(→ Tuple[str, str])

(container, path inside it).

precomputed_scale(→ Tuple[str, Optional[int]])

(volume, scale index) for a precomputed path: a last component

precomputed_volume(→ Tuple[str, int])

(volume location, scale index) for a precomputed path: the volume's

Module Contents

cellmap_flow.io.paths.ZARR_JSON = 'zarr.json'
cellmap_flow.io.paths.is_remote(path: str) → bool

An http(s), s3 or gs URL.

cellmap_flow.io.paths.is_precomputed(path: str) → bool

A precomputed:// path, or a gs:// one that names no zarr or N5 container (neuroglancer’s cloud volumes are precomputed).

cellmap_flow.io.paths.normalize_path(path: str) → str

Remove shell-escape backslashes from a filesystem path.

Users often copy-paste paths from a terminal where spaces are escaped (e.g. /path/to/file\ name.zarr). YAML preserves the literal backslashes, but the filesystem expects plain spaces.

A URL – http(s), s3, gs, or one after precomputed:// – is returned as it is: it is not a filesystem path.

cellmap_flow.io.paths.join(base: str, *parts: str) → str

Join path components; a URL is joined with “/” whatever the OS.

cellmap_flow.io.paths.parent(path: str) → str

The directory above path, a URL’s as a local path’s; a URL’s root (s3://bucket) is its own.

cellmap_flow.io.paths.is_v3_container(path: str) → bool

True if path is a directory with a zarr.json at its root.

cellmap_flow.io.paths.find_v3_container(path: str) → str | None

The nearest directory at or above path holding a zarr.json.

None if there is none (a v2 store), path is a URL (zarr v3 is read from the local filesystem only), or path does not exist: a missing level is not the group above it, whose zarr.json would otherwise answer for it.

cellmap_flow.io.paths.is_zarr_container(path: str) → bool

A local zarr (v2 or v3) group or array, with or without a .zarr suffix.

cellmap_flow.io.paths.suffix_format(path: str) → str | None

“zarr” or “n5”: the suffix of the last component of path that ends in .zarr or .n5; else None.

cellmap_flow.io.paths.split_container(path: str) → Tuple[str, str]

(container, path inside it).

The container ends at the last component of path ending in .zarr/.n5; without one it is the nearest directory up from path with a .zgroup (or, failing that, the first with a .zarray), on disk or at a URL alike. /data/x.zarr/em/s0 is ("/data/x.zarr", "em/s0").

cellmap_flow.io.paths.precomputed_scale(path: str) → Tuple[str, int | None]

(volume, scale index) for a precomputed path: a last component s<N> names scale N of the volume above it; a path without one is the volume itself, with index None.

cellmap_flow.io.paths.precomputed_volume(path: str) → Tuple[str, int]

(volume location, scale index) for a precomputed path: the volume’s local directory or URL, which io.store reads, and the scale a trailing /s<N> names (precomputed_scale), else 0.

precomputed:// followed by a URL – neuroglancer’s way of writing a cloud source, precomputed://gs://bucket/volume or precomputed://https://host/volume – is that URL, as is a bare gs:// path. Any other precomputed:// path is a local directory.