Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dandi/bids_validator_deno/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Package providing an interface to the deno-compiled BIDS validator"""

from ._validator import bids_validate, get_version

__all__ = ["bids_validate", "get_version"]


def __dir__() -> list[str]:
return list(__all__) # return a copy of `__all__` to avoid modifying the original

Check warning on line 9 in dandi/bids_validator_deno/__init__.py

View check run for this annotation

Codecov / codecov/patch

dandi/bids_validator_deno/__init__.py#L9

Added line #L9 was not covered by tests
78 changes: 78 additions & 0 deletions dandi/bids_validator_deno/_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This file holds the models used to interface with the deno-compiled BIDS validator
# with the `--json` option. The defined entities in this file share the same names and
# structure as those defined in
# https://github.com/bids-standard/bids-validator/blob/main/src/types/validation-result.ts
# and
# https://github.com/bids-standard/bids-validator/blob/main/src/issues/datasetIssues.ts
# The only exception to that rule is that the `ValidationResult` type in the
# BIDS validator source is named `BidsValidationResult` in this file.

from __future__ import annotations

from enum import auto
from typing import Any, Literal, Optional, Union

from pydantic import BaseModel, ConfigDict

from dandi.utils import StrEnum


class BidsValidationResult(BaseModel):
issues: DatasetIssues
summary: SummaryOutput
derivativesSummary: Optional[dict[str, BidsValidationResult]] = None

model_config = ConfigDict(strict=True)


class DatasetIssues(BaseModel):
issues: list[Issue]
codeMessages: dict[str, str]

model_config = ConfigDict(strict=True)


class Issue(BaseModel):
code: str
subCode: Optional[str] = None
severity: Optional[Severity] = None
location: Optional[str] = None
issueMessage: Optional[str] = None
suggestion: Optional[str] = None
affects: Optional[list[str]] = None
rule: Optional[str] = None
line: Optional[int] = None
character: Optional[int] = None

model_config = ConfigDict(strict=True)


class Severity(StrEnum):
warning = auto()
error = auto()
ignore = auto()


class SummaryOutput(BaseModel):
sessions: list[str]
subjects: list[str]
subjectMetadata: list[SubjectMetadata]
tasks: list[str]
modalities: list[str]
secondaryModalities: list[str]
totalFiles: int
size: int
dataProcessed: bool
pet: dict[str, Any]
dataTypes: list[str]
schemaVersion: str

model_config = ConfigDict(strict=True)


class SubjectMetadata(BaseModel):
participantId: str
age: Union[int, Literal["89+"], None] = None
sex: Optional[str] = None

model_config = ConfigDict(strict=True)
Loading