From ec54f2833be3860f7f3f7140dadae83c21952d07 Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Fri, 25 Aug 2023 16:49:29 +0200 Subject: [PATCH] bug fix, `type`/`io_class_name` may be None --- api/data_handler.py | 2 +- api/resources/v1.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/data_handler.py b/api/data_handler.py index 0584695..53c20d3 100644 --- a/api/data_handler.py +++ b/api/data_handler.py @@ -91,7 +91,7 @@ def load_block(url, io_class_name=None): # todo: handle formats with multiple files, or with a directory if io_class_name: # todo: handle an invalid class name - io_cls = getattr(neo.io, io_class_name) + io_cls = getattr(neo.io, io_class_name.value) try: io = io_cls(filename=file_path) except ImportError: diff --git a/api/resources/v1.py b/api/resources/v1.py index d29dba2..31a9e06 100644 --- a/api/resources/v1.py +++ b/api/resources/v1.py @@ -56,7 +56,7 @@ async def get_block_data( but without any information about the data contained within each segment. """ # here `url` is a Pydantic object, which we convert to a string - block = load_block(str(url), type.value) + block = load_block(str(url), type) return BlockContainer.from_neo(block, url) @@ -86,7 +86,7 @@ async def get_segment_data( including metadata about the signals contained in the segment, but not the signal data themselves. """ - block = load_block(str(url), type.value) + block = load_block(str(url), type) try: segment = block.segments[segment_id] except IndexError: @@ -129,7 +129,7 @@ async def get_analogsignal_data( ] = 1, ) -> AnalogSignal: """Get an analog signal from a given segment, including both data and metadata.""" - block = load_block(str(url), type.value) + block = load_block(str(url), type) try: segment = block.segments[segment_id] except IndexError: @@ -173,7 +173,7 @@ async def get_spiketrain_data( ] = None, ) -> dict[str, SpikeTrain]: """Get the spike trains from a given segment, including both data and metadata.""" - block = load_block(str(url), type.value) + block = load_block(str(url), type) try: segment = block.segments[segment_id] except IndexError: