tighten up error reporting (#1269)

* black reformat

* tighten up error reporting

* lint

* fine tuning

* additional improvements in exception handling

* lint

* include exception and traceback in log

* fix typo
This commit is contained in:
Bruce Martin
2020-03-22 09:55:47 -07:00
committed by GitHub
parent 8180be83b8
commit db7a485796
9 changed files with 124 additions and 129 deletions
+7 -8
View File
@@ -44,9 +44,9 @@ class AnndataAdaptor(DataAdaptor):
# try to read it. Many of these tests don't make sense for URIs (eg, extension-
# based typing).
if not data_locator.exists():
raise DatasetAccessError(f"{data_locator.uri_or_path} does not exist")
raise DatasetAccessError("does not exist")
if not data_locator.isfile():
raise DatasetAccessError(f"{data_locator.uri_or_path} is not a file")
raise DatasetAccessError("is not a file")
@staticmethod
def file_size(data_locator):
@@ -172,10 +172,10 @@ class AnndataAdaptor(DataAdaptor):
)
except MemoryError:
raise DatasetAccessError("Out of memory - file is too large for available memory.")
except Exception as e:
except Exception:
raise DatasetAccessError(
f"{e} - file not found or is inaccessible. File must be an .h5ad object. "
f"Please check your input and try again."
"File not found or is inaccessible. File must be an .h5ad object. "
"Please check your input and try again."
)
def _validate_and_initialize(self):
@@ -310,9 +310,8 @@ class AnndataAdaptor(DataAdaptor):
try:
shape = self.get_shape()
obs_mask = self._axis_filter_to_mask(Axis.OBS, obsFilter["obs"], shape[0])
except (KeyError, IndexError) as e:
raise FilterError(f"Error parsing filter: {e}") from e
except (KeyError, IndexError):
raise FilterError("Error parsing filter")
with ServerTiming.time("layout.compute"):
X_umap = scanpy_umap(self.data, obs_mask)
normalized_layout = DataAdaptor.normalize_embedding(X_umap)