Data Classes and Check Registration
All common data class used across the package, as well as the decorator for adding a check function to the registry.
Primary decorator used on a check function to add it to the registry and automatically parse its output.
- class Importance(*values)
Bases:
EnumA definition of the valid importance levels for a given check function.
- class Severity(*values)
Bases:
EnumA definition of the valid severity levels for the output from a given check function.
Strictly for internal development that improves report organization; users should never directly see these values.
- class InspectorMessage(message: str, importance: Importance = Importance.BEST_PRACTICE_SUGGESTION, severity: Severity = Severity.LOW, check_function_name: str | None = None, object_type: str | None = None, object_name: str | None = None, location: str | None = None, file_path: str | None = None)
Bases:
objectThe primary output to be returned by every check function.
- Parameters:
message (str) – A message that informs the user of the violation.
severity (Severity, optional) – If a check of non-CRITICAL importance has some basis of comparison, such as magnitude of affected data, then the developer of the check may set the severity as Severity.HIGH or Severity.LOW by calling from nwbinspector.register_checks import Severity. A good example is comparing if h5py.Dataset compression has been enabled on smaller vs. larger objects (see nwbinspector/checks/nwb_containers.py for details).
The user will never directly see this severity, but it will prioritize the order in which check results are presented by the NWBInspector.
importance (Importance) – The Importance level specified by the decorator of the check function.
check_function_name (str) – The name of the check function the decorator was applied to.
object_type (str) – The specific class of the instantiated object being inspected.
object_name (str) – The name of the instantiated object being inspected.
location (str) – The location relative to the root of the NWBFile where the inspected object may be found.
file_path (str) – The path of the NWBFile this message pertains to Relative to the path called from inspect_nwb, inspect_all, or the path specified at the command line.
- __repr__()
Representation for InspectorMessage objects according to black format.
Primary decorator used on a check function to add it to the registry and automatically parse its output.
- register_check(importance: Importance, neurodata_type: object, nwb_schema_version_lt: str | None = None, nwb_schema_version_gt: str | None = None) Callable
Wrap a check function with this decorator to add it to the check registry and automatically parse some output.
- Parameters:
importance (Importance) –
- Importance has three levels:
- CRITICAL
potentially incorrect data
- BEST_PRACTICE_VIOLATION
very suboptimal data representation
- BEST_PRACTICE_SUGGESTION
improvable data representation
neurodata_type – The most generic HDMF/PyNWB class the check function applies to. Should generally match the type annotation of the check. If this check is intended to apply to any general NWBFile object, set neurodata_type to None.
nwb_schema_version_lt (str, optional) – Only run this check on NWB files with schema version less than this value. Useful for checks that only apply to older schema versions.
nwb_schema_version_gt (str, optional) – Only run this check on NWB files with schema version greater than this value. Useful for checks that only apply to newer schema versions.
- _auto_parse(check_function: Callable, neurodata_object: object, result: InspectorMessage | None = None) InspectorMessage | None
Automatically fill values in the InspectorMessage from the check function.
- _parse_location(neurodata_object: object) str | None
Grab the object location from a dataset or a container content that is an dataset object.