Skip to content

metadata_schema

Scan Metadata Schema ModuleLink

Defines the canonical MIAPPE-aligned structure for the biological metadata of a Scan and a lightweight validator that checks it (no external dependency).

The biological metadata lives in the scan's metadata/metadata.json under the top-level MIAPPE sections: investigation, study, biologicalMaterial and observedVariable. The validator only inspects these keys when present: a scan without biological metadata is valid (the block is optional), but if a section is provided its known fields are type-checked.

See docs/developers/miappe_metadata.md for the full mapping and design.

validate_biological_metadata Link

validate_biological_metadata(metadata)

Validate the MIAPPE biological block of metadata.

Parameters:

Name Type Description Default

metadata Link

dict

The scan metadata dictionary.

required

Raises:

Type Description
ValueError

If a present MIAPPE section contains a field of the wrong type.

Source code in plantdb/commons/fsdb/metadata_schema.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
def validate_biological_metadata(metadata: dict[str, Any]) -> None:
    """Validate the MIAPPE biological block of ``metadata``.

    Parameters
    ----------
    metadata : dict
        The scan metadata dictionary.

    Raises
    ------
    ValueError
        If a present MIAPPE section contains a field of the wrong type.
    """
    if not isinstance(metadata, dict):
        raise ValueError("Scan metadata must be a dictionary")
    errors: list[str] = []
    for section, schema in SCAN_BIOLOGICAL_SCHEMA.items():
        if section in metadata:
            _check(metadata[section], schema, section, errors)
    if errors:
        raise ValueError("Invalid biological metadata: " + "; ".join(errors))