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 <tihuan@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
rwbaber
2026-01-14 17:22:22 +00:00
committed by GitHub
parent 0fddcd042a
commit 2b86f8e600

View File

@@ -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)