dandi.validate

Validation of DANDI datasets against schemas and standards.

This subpackage provides validation functionality for dandisets, including: - DANDI schema validation - BIDS standard validation - File layout and organization validation - Metadata completeness checking

Private submodules: - _core: Main validation functions (validate, validate_bids) - _types: Data types and models (ValidationResult, Origin, Severity, etc.) - _io: JSONL read/write utilities for validation results

Note: _core is NOT eagerly imported here to avoid circular imports (_core → dandi.files → dandi.validate._types → dandi.validate.__init__). Import from dandi.validate._core directly for validate/validate_bids.

class dandi.validate.MissingFileContent(value)[source]

Policy for handling files whose content is missing (e.g. broken symlinks in a datalad dataset without fetched data).

error = 'error'

Emit a concise error for each file with missing content (default).

only_non_data = 'only-non-data'

Skip content-dependent validators (e.g. pynwb, nwbinspector) but still validate non-data aspects such as path layout.

skip = 'skip'

Skip the file entirely; emit a WARNING noting that validation was skipped.

class dandi.validate.Origin(*, type: OriginType, validator: Validator, validator_version: str, standard: Standard | None = None, standard_version: str | None = None, standard_schema_version: str | None = None)[source]

Origin of the validation result

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

standard: Standard | None

Standard being validated against

standard_schema_version: str | None

Version of the schema used in defining or implementing the standard, such as BIDS schema version in BIDS

standard_version: str | None

Version of the standard

type: OriginType
validator: Validator

The validator conducting the validation

validator_version: str

The version of the validator

class dandi.validate.OriginType(value)[source]

Types of validation result origins

INTERNAL = 'INTERNAL'

Validation result is originated from the validator but not necessarily relating to validation of the data

VALIDATION = 'VALIDATION'

Validation result is originated from validation of the data

class dandi.validate.Scope(value)[source]

An enumeration.

DANDISET = 'dandiset'
DATASET = 'dataset'
FILE = 'file'
FOLDER = 'folder'
class dandi.validate.Severity(value)[source]

Severity levels for validation results

CRITICAL = 50

A serious invalidity in data. E.g., an invalidity that prevents validation of other aspects of the data such as when validating against the BIDS standard, the data is without a BIDSVersion field or has an invalid BIDSVersion field.

ERROR = 40

Data is recognized as invalid

HINT = 20

Data is valid but could be improved

INFO = 10

Not an indication of problem but information of status or confirmation

WARNING = 30

Data is not recognized as valid. Changes are needed to ensure validity

class dandi.validate.Standard(value)[source]

Standards to validate against

BIDS = 'BIDS'
DANDI_LAYOUT = 'DANDI-LAYOUT'
DANDI_SCHEMA = 'DANDI-SCHEMA'
HED = 'HED'
JSON = 'JSON'
NWB = 'NWB'
OME_ZARR = 'OME-ZARR'
TSV = 'TSV'
YAML = 'YAML'
ZARR = 'ZARR'
class dandi.validate.ValidationResult(*, record_version: str = '1', id: str, origin: ~dandi.validate._types.Origin, scope: ~dandi.validate._types.Scope, origin_result: ~typing.Any | None = None, severity: ~dandi.validate._types.Annotated[~dandi.validate._types.Severity, ~pydantic.functional_validators.BeforeValidator(func=~dandi.validate._types._accept_severity_by_name, json_schema_input_type=~dandi.validate._types.Severity | ~dandi.validate._types._SeverityName), ~pydantic.functional_serializers.PlainSerializer(func=~dandi.validate._types.<lambda>, return_type=~dandi.validate._types._SeverityName, when_used=json)] | None = None, asset_paths: list[str] | None = None, within_asset_paths: dict[str, str] | None = None, dandiset_path: ~pathlib.Path | None = None, dataset_path: ~pathlib.Path | None = None, message: str | None = None, metadata: dict | None = None, path: ~pathlib.Path | None = None, path_regex: str | None = None)[source]
asset_paths: list[str] | None
dandiset_path: Path | None
dataset_path: Path | None
id: str
message: str | None
metadata: dict | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(_ValidationResult__context: Any) None[source]

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

origin: Origin

Origin of the validation result as validator and standard used in producing it

origin_result: Any | None

The representation of the validation result produced by the used validator, self.origin.validator, unchanged

path: Path | None
path_regex: str | None
property purview: str | None
record_version: str

Version of the serialized record format for forward compatibility

scope: Scope
severity: Severity_ | None
within_asset_paths: dict[str, str] | None
class dandi.validate.Validator(value)[source]

Validators that are used to do validation

bids_validator_deno = 'bids-validator-deno'
bidsschematools = 'bidsschematools'
dandi = 'dandi'
dandi_zarr = 'dandi.zarr'
dandischema = 'dandischema'
hed_python_validator = 'hed-python-validator'
nwbinspector = 'nwbinspector'
pynwb = 'pynwb'
tensorstore = 'tensorstore'
zarr = 'zarr'
dandi.validate.load_validation_jsonl(paths: Iterable[str | Path]) list[ValidationResult][source]

Load and concatenate validation results from one or more JSONL files.

Parameters:

paths – Iterable of file paths to load from.

Returns:

All results from all files, in order.

Return type:

list[ValidationResult]

dandi.validate.validation_companion_path(logfile: str | Path) Path[source]

Derive the validation companion path from a logfile path.

The companion is placed next to the logfile with _validation.jsonl appended to the stem.

Parameters:

logfile – Path to the logfile.

Returns:

Path to the companion file.

Return type:

Path

dandi.validate.write_validation_jsonl(results: list[ValidationResult], path: str | Path, *, append: bool = False) Path[source]

Write validation results to a JSONL file.

Parameters:
  • results – List of ValidationResult objects to write.

  • path – File path to write to. Created if it does not exist.

  • append – If True, append to an existing file instead of overwriting.

Returns:

The path written to (as a Path object).

Return type:

Path