Skip to content

load_schemas

build_registry() cached

Build a JSON-referencing registry including all schemas from this package.

Returns:

Type Description
Registry

The complete registry.

Source code in python/src/ngff_rfc8/load_schemas.py
@cache
def build_registry() -> Registry:
    """
    Build a JSON-referencing registry including all schemas from this package.

    Returns:
        The complete registry.
    """
    registry = Registry()
    for path in get_list_schema_files():
        schema = json.loads(path.read_text())
        registry = registry.with_resource(
            schema["$id"],
            Resource.from_contents(schema),
        )
    return registry

get_list_schema_files() cached

Get list of JSON Schema files.

Returns:

Type Description
list[Path]

List of JSON Schema paths.

Source code in python/src/ngff_rfc8/load_schemas.py
@cache
def get_list_schema_files() -> list[Path]:
    """
    Get list of JSON Schema files.

    Returns:
        List of JSON Schema paths.
    """
    return list(sorted(_SCHEMA_DIR.glob("*.json")))

get_ome_schema() cached

Get ome JSON Schema.

Returns:

Type Description
JSONSchemaType

JSON Schema for ome data.

Source code in python/src/ngff_rfc8/load_schemas.py
@cache
def get_ome_schema() -> JSONSchemaType:
    """
    Get `ome` JSON Schema.

    Returns:
        JSON Schema for `ome` data.
    """
    return get_schema("ome")

get_schema(name) cached

Get JSON Schema named name.

Parameters:

Name Type Description Default
name str

Name of the schema (e.g. node, collection, multiscale, ...).

required

Returns:

Type Description
JSONSchemaType

The JSON Schema named name.

Source code in python/src/ngff_rfc8/load_schemas.py
@cache
def get_schema(name: str) -> JSONSchemaType:
    """
    Get JSON Schema named `name`.

    Arguments:
        name: Name of the schema (e.g. `node`, `collection`, `multiscale`, ...).

    Returns:
        The JSON Schema named `name`.
    """
    schema = json.loads((_SCHEMA_DIR / f"{name}.json").read_text())
    return schema