neu_vol.dvid¶
Addressing a DVID instance, and resolving which version of it you get.
Instance-type agnostic: it addresses an instance, resolves a ref to a node and records
that node, for a labelmap, annotation or keyvalue alike, so neu-mark can use
it without an array. The labelmap geometry and array view are in backends/dvid.py.
Also here: fetching DVID ROIs as one positioned label array (roi_volume()).
A uuid may be a branch ref, which names a node that moves: resolve it once, in the
driver (resolve_node()).
Attributes¶
Classes¶
A combined ROI label array, positioned in nm. |
Functions¶
|
|
|
Every |
|
Require the instance to be one of |
|
Drop memoized ref resolutions (tests, and any long-lived process). |
|
|
|
DVID's |
|
The instance's DVID type name — |
|
True if this location names a DVID instance rather than a store. |
|
What a pull came from, for the record written beside the output. |
|
Both candidate nodes for a ref: what it points at now, and the newest locked one. |
|
|
|
Resolve this spec's |
|
Validate an ROI name list against the node before fetching any of them. |
|
The |
|
Fetch the named ROIs as one label array with its |
|
The |
|
Instances this one is synced to, from |
Module Contents¶
- class neu_vol.dvid.RoiVolume¶
A combined ROI label array, positioned in nm.
labels[z, y, x] == imeans block(z, y, x)belongs tonames[i - 1]; 0 is in none. Where ROIs intersect the one named later holds the voxel, andoverlapsrecords each intersecting pair with its size in blocks.- mask(*names: str) numpy.ndarray¶
Boolean array of the named ROIs (all of them when none are named).
- frame: neu_lib.Frame¶
- labels: numpy.ndarray¶
- names: tuple[str, ...]¶
- overlaps: tuple[tuple[str, str, int], ...] = ()¶
- neu_vol.dvid.address(spec: Mapping[str, Any]) tuple[str, str, str]¶
(server, uuid, instance)— the argument triple every neuclease call takes.
- neu_vol.dvid.available_rois(spec: Mapping[str, Any]) list[str]¶
Every
roiinstance on this node.
- neu_vol.dvid.check_instance_type(info: Mapping[str, Any], spec: Mapping[str, Any], *expected: str) str¶
Require the instance to be one of
expected, else raise. Returns its type.
- neu_vol.dvid.clear_node_cache() None¶
Drop memoized ref resolutions (tests, and any long-lived process).
- neu_vol.dvid.fetch_roi_ranges(spec: Mapping[str, Any], rois: Sequence[str], *, processes: int = 0) tuple[list[str], dict, dict]¶
(names, ranges, boxes): the fetch half of building an ROI volume, one request per ROI, separate so the ranges can be unpacked more than once.boxesomits any ROI that holds no blocks.
- neu_vol.dvid.instance_info(spec: Mapping[str, Any]) dict¶
DVID’s
/infofor this instance: one request, no backend opened.
- neu_vol.dvid.instance_type(info: Mapping[str, Any]) str | None¶
The instance’s DVID type name —
labelmap,annotation,keyvalue, …
- neu_vol.dvid.is_url(location: Any) bool¶
True if this location names a DVID instance rather than a store.
- neu_vol.dvid.node_provenance(spec: Mapping[str, Any], node: Mapping[str, Any]) dict¶
What a pull came from, for the record written beside the output.
The resolved
uuididentifies the snapshot;requestedkeeps the ref as typed. The node’s DAG metadata is recorded too (DVID has no per-instance mutation id). Callers add fields describing their own read.
- neu_vol.dvid.node_summary(spec: Mapping[str, Any]) dict¶
Both candidate nodes for a ref: what it points at now, and the newest locked one.
Returns
{"head": node, "locked": node | None, "locked_error": str | None};lockedisheadwhen the ref already points at a locked node, andNonewhen no locked node is reachable.
- neu_vol.dvid.parse_url(url: str) dict[str, str]¶
dvid://<server>/<uuid>/<instance>-> the spec fields.Exactly three segments, split on
/only:servermay carry a port (emdata3:8900); a bare host getshttp://from neuclease. Use thedvid+https://scheme for a TLS server.uuidmay be a full or abbreviated uuid, or theuuid:branchform (93fdbc:main).instanceis the data instance name; the caller checks its type.
- neu_vol.dvid.resolve_node(spec: Mapping[str, Any], *, prefer_locked: bool = False) dict¶
Resolve this spec’s
uuidref to a concrete node, and say if it is locked.A branch ref (
93fdbc:main) resolves to the branch HEAD, which in a lock-and-spawn workflow is the open, still-mutable node. Resolve once, in the driver, and hand workers the concrete uuid: per-worker resolution could read two versions if HEAD moves mid-run.prefer_lockedwalks back to the newest locked node with DVID’sref~Nsyntax, which needs therepo:branchform. Returns{"ref", "uuid", "locked", "walked"}.
- neu_vol.dvid.resolve_roi_set(spec: Mapping[str, Any], rois: Sequence[str]) list[str]¶
Validate an ROI name list against the node before fetching any of them.
The order given is kept: it decides which ROI wins where two intersect.
- neu_vol.dvid.roi_frame(box_lo_blocks: Sequence[int], voxel_size_nm: Sequence[float], origin_nm: Sequence[float] = (0.0, 0.0, 0.0)) neu_lib.Frame¶
The
Frameof an ROI array whose voxel(0, 0, 0)is blockbox_lo.voxel_size_nmandorigin_nmdescribe the scale-0 grid the node indexes, which DVID does not record.
- neu_vol.dvid.roi_volume(spec: Mapping[str, Any], rois: Sequence[str], *, voxel_size_nm: Sequence[float], origin_nm: Sequence[float] = (0.0, 0.0, 0.0), processes: int = 0) RoiVolume¶
Fetch the named ROIs as one label array with its
Frame.specaddresses any instance on the node (ROIs are per node).voxel_size_nm/origin_nmare the scale-0 grid’s (seeroi_frame()). An ROI holding no blocks raises.
- neu_vol.dvid.spec_url(spec: Mapping[str, Any]) str¶
The
dvid://URL for a spec — for messages and provenance.
- neu_vol.dvid.synced_instances(info: Mapping[str, Any]) list[str]¶
Instances this one is synced to, from
Base.Syncs.An annotation instance answers
/label/<id>only when synced to a labelmap, so callers check this before fetching per body.
- neu_vol.dvid.MISSING = Multiline-String¶
Show Value
"""Talking to DVID needs the `neuclease` package, which is not installed here. neuclease cannot be a pip dependency: it needs `libdvid-cpp`, `vigra` and `dvidutils`, which are conda-only on flyem-forge — and libdvid is load-bearing rather than incidental, since it is what inflates DVID's compressed label blocks. Install it into the environment instead: mamba install -n neu-env -c flyem-forge -c conda-forge neuclease"""
- neu_vol.dvid.ROI_BLOCK_VOXELS = 32¶
- neu_vol.dvid.ROI_INSTANCE = 'roi'¶