From 2b86f8e600d9f0e1dbe34768fb8d8c519c2f85a4 Mon Sep 17 00:00:00 2001 From: rwbaber <97636743+rwbaber@users.noreply.github.com> Date: Wed, 14 Jan 2026 17:22:22 +0000 Subject: [PATCH] fix: improve anndata error msg (#2743) * feat: improve error message for anndata version mismatches * fix: Remove mentioning of python update and only mention upgrading anndata * Update server/data_anndata/anndata_adaptor.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Timmy Huang Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- server/data_anndata/anndata_adaptor.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/server/data_anndata/anndata_adaptor.py b/server/data_anndata/anndata_adaptor.py index aa20a05f..59d0a494 100644 --- a/server/data_anndata/anndata_adaptor.py +++ b/server/data_anndata/anndata_adaptor.py @@ -173,13 +173,24 @@ class AnndataAdaptor(DataAdaptor): ) except MemoryError: raise DatasetAccessError("Out of memory - file is too large for available memory.") - except Exception: + except Exception as e: import traceback + error_msg = str(e) + + # IMPROVEMENT: Broadly catch ANY version incompatibility + if "No read method registered" in error_msg and "IOSpec" in error_msg: + message = ( + "Error loading file: This H5AD file uses a newer internal format that " + "your version of 'anndata' cannot read.\n" + f"The specific error was: {error_msg}\n" + "Please upgrade anndata in your environment (pip install --upgrade anndata)." + ) + else: + message = ( + "File not found or is inaccessible. File must be an .h5ad object. " + "Please check your input and try again." + ) - message = ( - "File not found or is inaccessible. File must be an .h5ad object. " - "Please check your input and try again." - ) if self.server_config.app__verbose: message += f"\n{traceback.format_exc()}" raise DatasetAccessError(message)