From b01efebbe5adaf741f69f38a8b6d8ca3039db94f Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:57:28 -0400 Subject: [PATCH] [Pydantic IVb] Pydantic validation on arrays (#1055) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- CHANGELOG.md | 3 ++- .../ecephys/spikegadgets/spikegadgetsdatainterface.py | 4 ++-- .../datainterfaces/ecephys/spikeglx/spikeglxnidqinterface.py | 4 ++-- src/neuroconv/datainterfaces/ophys/hdf5/hdf5datainterface.py | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b75247d48..cd1580540 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Features * Make `config_file_path` optional in `DeepLabCutInterface`[PR #1031](https://github.com/catalystneuro/neuroconv/pull/1031) * Added `get_stream_names` to `OpenEphysRecordingInterface`: [PR #1039](https://github.com/catalystneuro/neuroconv/pull/1039) +* Most data interfaces and converters now use Pydantic to validate their inputs, including existence of file and folder paths. [PR #1022](https://github.com/catalystneuro/neuroconv/pull/1022) +* All remaining data interfaces and converters now use Pydantic to validate their inputs, including existence of file and folder paths. [PR #1055](https://github.com/catalystneuro/neuroconv/pull/1055) ### Improvements * Using ruff to enforce existence of public classes' docstrings [PR #1034](https://github.com/catalystneuro/neuroconv/pull/1034) @@ -41,7 +43,6 @@ * Added helper function `neuroconv.tools.data_transfers.submit_aws_batch_job` for basic automated submission of AWS batch jobs. [PR #384](https://github.com/catalystneuro/neuroconv/pull/384) * Data interfaces `run_conversion` method now performs metadata validation before running the conversion. [PR #949](https://github.com/catalystneuro/neuroconv/pull/949) * Introduced `null_values_for_properties` to `add_units_table` to give user control over null values behavior [PR #989](https://github.com/catalystneuro/neuroconv/pull/989) -* Most data interfaces and converters now use Pydantic to validate their inputs, including existence of file and folder paths. [PR #1022](https://github.com/catalystneuro/neuroconv/pull/1022) ### Bug fixes * Fixed the default naming of multiple electrical series in the `SpikeGLXConverterPipe`. [PR #957](https://github.com/catalystneuro/neuroconv/pull/957) diff --git a/src/neuroconv/datainterfaces/ecephys/spikegadgets/spikegadgetsdatainterface.py b/src/neuroconv/datainterfaces/ecephys/spikegadgets/spikegadgetsdatainterface.py index 4a63dc237..b8b483dd0 100644 --- a/src/neuroconv/datainterfaces/ecephys/spikegadgets/spikegadgetsdatainterface.py +++ b/src/neuroconv/datainterfaces/ecephys/spikegadgets/spikegadgetsdatainterface.py @@ -1,6 +1,6 @@ from typing import Optional -from pydantic import FilePath +from pydantic import ConfigDict, FilePath, validate_call from ..baserecordingextractorinterface import BaseRecordingExtractorInterface from ....utils import ArrayType, get_json_schema_from_method_signature @@ -22,7 +22,7 @@ def get_source_schema(cls) -> dict: source_schema["properties"]["file_path"].update(description="Path to SpikeGadgets (.rec) file.") return source_schema - # @validate_call + @validate_call(config=ConfigDict(arbitrary_types_allowed=True)) def __init__( self, file_path: FilePath, diff --git a/src/neuroconv/datainterfaces/ecephys/spikeglx/spikeglxnidqinterface.py b/src/neuroconv/datainterfaces/ecephys/spikeglx/spikeglxnidqinterface.py index 9e903f3f1..42dad773d 100644 --- a/src/neuroconv/datainterfaces/ecephys/spikeglx/spikeglxnidqinterface.py +++ b/src/neuroconv/datainterfaces/ecephys/spikeglx/spikeglxnidqinterface.py @@ -1,7 +1,7 @@ from pathlib import Path import numpy as np -from pydantic import FilePath +from pydantic import ConfigDict, FilePath, validate_call from .spikeglx_utils import get_session_start_time from ..baserecordingextractorinterface import BaseRecordingExtractorInterface @@ -25,7 +25,7 @@ def get_source_schema(cls) -> dict: source_schema["properties"]["file_path"]["description"] = "Path to SpikeGLX .nidq file." return source_schema - # @validate_call + @validate_call(config=ConfigDict(arbitrary_types_allowed=True)) def __init__( self, file_path: FilePath, diff --git a/src/neuroconv/datainterfaces/ophys/hdf5/hdf5datainterface.py b/src/neuroconv/datainterfaces/ophys/hdf5/hdf5datainterface.py index 2526f7fb3..025e68b87 100644 --- a/src/neuroconv/datainterfaces/ophys/hdf5/hdf5datainterface.py +++ b/src/neuroconv/datainterfaces/ophys/hdf5/hdf5datainterface.py @@ -1,6 +1,6 @@ from typing import Literal -from pydantic import FilePath +from pydantic import ConfigDict, FilePath, validate_call from ..baseimagingextractorinterface import BaseImagingExtractorInterface from ....utils import ArrayType @@ -13,7 +13,7 @@ class Hdf5ImagingInterface(BaseImagingExtractorInterface): associated_suffixes = (".h5", ".hdf5") info = "Interface for HDF5 imaging data." - # @validate_call + @validate_call(config=ConfigDict(arbitrary_types_allowed=True)) def __init__( self, file_path: FilePath,