ngff_zarr.rfc4_conformance

RFC 4 conformance output for the ngff-zarr CLI.

ngff-zarr conformance <input> prints one JSON verdict per input – the shape a tool-agnostic conformance driver feeds against its manifest to check that an implementation follows RFC 4:

{"input": ..., "format": "ome-zarr", "rfc4_valid": bool,
 "axes": {name: value}, "violations": [code, ...], "warnings": [code, ...]}

It reads the raw axes, so malformed metadata is still classifiable – the high-level reader would reject it before it could be reported. Findings are reported with the conformance contract’s code names: RFC 4 defines no error codes, and the package’s own :class:~ngff_zarr.structural_validation.SpecRule identifiers are a different vocabulary, so the classification here is deliberately expressed in the contract’s terms while applying the same RFC 4 rules as

func:

~ngff_zarr.rfc4_validation.validate_rfc4_orientation.

Module Contents

Functions

_axes_from_metadata

Pull multiscales[0].axes out of a v2 .zattrs or v3 zarr.json blob.

_load_json

Parse metadata JSON, classifying a decode failure as an unreadable input.

_read_axes

Read the raw axis dicts from an OME-Zarr directory or .zip.

_classify

Classify RFC 4 findings using the conformance contract’s code vocabulary.

conformance_report

Build the canonical conformance verdict for one OME-Zarr input.

Data

API

ngff_zarr.rfc4_conformance._METADATA_NAMES

(‘zarr.json’, ‘.zattrs’)

exception ngff_zarr.rfc4_conformance._UnreadableInput(code: str, message: str)

Bases: Exception

The input is not a readable OME-Zarr carrying an axes list.

Holds the conformance code to surface as the verdict violation, so an unreadable or non-OME-Zarr input is reported as invalid rather than silently treated as an empty (and therefore “valid”) axes list.

Initialization

Initialize self. See help(type(self)) for accurate signature.

ngff_zarr.rfc4_conformance._axes_from_metadata(meta: Any) list[dict[str, Any]]

Pull multiscales[0].axes out of a v2 .zattrs or v3 zarr.json blob.

ngff_zarr.rfc4_conformance._load_json(raw: bytes | str, source: str) Any

Parse metadata JSON, classifying a decode failure as an unreadable input.

ngff_zarr.rfc4_conformance._read_axes(path: str) list[dict[str, Any]]

Read the raw axis dicts from an OME-Zarr directory or .zip.

Raises :class:_UnreadableInput when no readable OME-Zarr metadata carrying an axes list is found, so the caller can emit an invalid verdict instead of an empty axes list.

ngff_zarr.rfc4_conformance._classify(axes: list[dict[str, Any]]) tuple[list[str], list[str]]

Classify RFC 4 findings using the conformance contract’s code vocabulary.

RFC 4 defines no error codes, so the names below belong to the conformance contract rather than to the specification. The rules applied are the RFC’s:

  • orientation MUST only be used on spatial axes;

  • an orientation object MUST carry a type (only "anatomical" is defined) and a value drawn from the controlled vocabulary;

  • a set of axes MUST only carry one direction of each antonym pair.

Orientation is optional per spatial axis, and an absent orientation is equivalent to an explicit null – neither is a violation – but a writer SHOULD omit the field rather than serialize null, which is reported as a warning. A code may repeat, once per offending axis.

ngff_zarr.rfc4_conformance.conformance_report(path: str) dict[str, Any]

Build the canonical conformance verdict for one OME-Zarr input.

An unreadable or non-OME-Zarr input yields an invalid verdict carrying the read-failure code, never rfc4_valid: true with empty axes.